Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-11-07 06:18:52
Exec Total Coverage
Lines: 1682 4269 39.4%
Functions: 132 333 39.6%
Branches: 933 3042 30.7%

Line Branch Exec Source
1 #include "zc/zc_sys.h"
2
3 #include "allegro/gfx.h"
4 #include "allegro5/joystick.h"
5 #include "base/qrs.h"
6 #include "base/dmap.h"
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <cstring>
10 #include <math.h>
11 #include <map>
12 #include <filesystem>
13 #include <ctype.h>
14 #include <sstream>
15 #include "base/zc_alleg.h"
16 #include "gamedata.h"
17 #include "zc/zc_init.h"
18 #include "init.h"
19 #include "zc/replay.h"
20 #include "zc/cheats.h"
21 #include "zc/render.h"
22 #include "base/zc_math.h"
23 #include "base/zapp.h"
24 #include "dialog/cheatkeys.h"
25 #include "metadata/metadata.h"
26 #include "zc/zelda.h"
27 #include "zc/saves.h"
28 #include "tiles.h"
29 #include "base/colors.h"
30 #include "pal.h"
31 #include "base/zsys.h"
32 #include "qst.h"
33 #include "zc/zc_sys.h"
34 #include "play_midi.h"
35 #include "gui/jwin_a5.h"
36 #include "base/jwinfsel.h"
37 #include "base/gui.h"
38 #include "midi.h"
39 #include "subscr.h"
40 #include "zc/maps.h"
41 #include "sprite.h"
42 #include "zc/guys.h"
43 #include "zc/hero.h"
44 #include "zc/title.h"
45 #include "particles.h"
46 #include "sound/zcmusic.h"
47 #include "zconsole.h"
48 #include "zc/ffscript.h"
49 #include "dialog/info.h"
50 #include "dialog/alert.h"
51 #include "zc/combos.h"
52 #include "zc/jit.h"
53 #include "zc/zc_subscr.h"
54 #include <fmt/format.h>
55 #include "zinfo.h"
56 #include "base/misctypes.h"
57 #include "music_playback.h"
58
59 #ifdef __EMSCRIPTEN__
60 #include "base/emscripten_utils.h"
61 #endif
62
63 using namespace std::chrono_literals;
64
65 extern FFScript FFCore;
66 extern bool Playing;
67 int32_t sfx_voice[WAV_COUNT];
68 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
69 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
70
71 static ALLEGRO_JOYSTICK* gamepad_dlg_cur_joystick;
72 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c);
73
74 extern byte monochrome_console;
75
76 extern HeroClass Hero;
77 extern zcmodule moduledata;
78 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
79 extern particle_list particles;
80 extern int32_t loadlast;
81 extern char *sfx_string[WAV_COUNT];
82 byte use_dwm_flush;
83 byte use_save_indicator;
84 int32_t paused_midi_pos = 0;
85 byte midi_suspended = 0;
86 byte zc_192b163_warp_compatibility;
87 char modulepath[2048];
88 bool epilepsyFlashReduction;
89 signed char pause_in_background_menu_init = 0;
90 byte pause_in_background = 0;
91 bool is_sys_pal = false;
92 static bool load_control_called_this_frame;
93 extern PALETTE* hw_palette;
94 extern bool update_hw_pal;
95 extern const char* dmaplist(int32_t index, int32_t* list_size);
96 int32_t getnumber(const char *prompt,int32_t initialval);
97
98 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
99 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
100
101 static const char *qst_module_name = "current_module";
102 #ifdef ALLEGRO_LINUX
103 static const char *samplepath = "samplesoundset/patches.dat";
104 #endif
105 char qst_files_path[2048];
106
107 #ifdef _MSC_VER
108 #define getcwd _getcwd
109 #endif
110
111 bool rF11();
112 bool rI();
113 bool rQ();
114 bool zc_key_pressed();
115
116 #ifdef _WIN32
117
118 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
119 extern "C"
120 {
121 typedef HRESULT(WINAPI *t_DwmFlush)();
122 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
123 }
124
125 void do_DwmFlush()
126 {
127 static HMODULE shell = LoadLibrary("dwmapi.dll");
128
129 if(!shell)
130 return;
131
132 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
133 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
134
135 BOOL enabled;
136 isEnabled(&enabled);
137
138 if(isEnabled)
139 flush();
140 }
141
142 #endif // _WIN32
143
144 83751 bool flash_reduction_enabled(bool check_qr)
145 {
146
4/4
✓ Branch 0 taken 81530 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 81074 times.
✓ Branch 3 taken 83295 times.
83751 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
147 }
148
149 // Dialogue largening
150 void large_dialog(DIALOG *d)
151 {
152 large_dialog(d, 1.5);
153 }
154
155 void large_dialog(DIALOG *d, float RESIZE_AMT)
156 {
157 if(!d[0].d1)
158 {
159 d[0].d1 = 1;
160 int32_t oldwidth = d[0].w;
161 int32_t oldheight = d[0].h;
162 int32_t oldx = d[0].x;
163 int32_t oldy = d[0].y;
164 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
165 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
166 d[0].w = int32_t(d[0].w*RESIZE_AMT);
167 d[0].h = int32_t(d[0].h*RESIZE_AMT);
168
169 for(int32_t i=1; d[i].proc !=NULL; i++)
170 {
171 // Place elements horizontally
172 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
173 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
174
175 if(d[i].proc != d_stringloader)
176 {
177 if(d[i].proc==d_bitmap_proc)
178 {
179 d[i].w *= 2;
180 }
181 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
182 }
183
184 // Place elements vertically
185 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
186 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
187
188 // Vertically resize elements
189 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
190 {
191 d[i].h = int32_t((double)d[i].h*1.5);
192 }
193 else if(d[i].proc == jwin_droplist_proc || d[i].proc == d_joylist_proc)
194 {
195 d[i].y += int32_t((double)d[i].h*0.25);
196 d[i].h = int32_t((double)d[i].h*1.25);
197 }
198 else if(d[i].proc==d_bitmap_proc)
199 {
200 d[i].h *= 2;
201 }
202 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
203
204 // Fix frames
205 if(d[i].proc == jwin_frame_proc)
206 {
207 d[i].x++;
208 d[i].y++;
209 d[i].w-=4;
210 d[i].h-=4;
211 }
212 }
213 }
214
215 for(int32_t i=1; d[i].proc!=NULL; i++)
216 {
217 if(d[i].proc==jwin_slider_proc)
218 continue;
219
220 // Bigger font
221 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc && d[i].proc != d_joylist_proc);
222
223 if(!d[i].dp2 && bigfontproc)
224 {
225 d[i].dp2 = get_zc_font(font_lfont_l);
226 }
227 else if(!bigfontproc)
228 {
229 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
230 }
231
232 // Make checkboxes work
233 if(d[i].proc == jwin_check_proc)
234 d[i].proc = jwin_checkfont_proc;
235 else if(d[i].proc == jwin_radio_proc)
236 d[i].proc = jwin_radiofont_proc;
237 }
238
239 jwin_center_dialog(d);
240 }
241
242
243 /**********************************/
244 /******** System functions ********/
245 /**********************************/
246
247 static char cfg_sect[] = "zeldadx"; //We need to rename this.
248 static char ctrl_sect[] = "Controls";
249 static char sfx_sect[] = "Volume";
250
251 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
252 {
253 return D_O_K;
254 }
255
256 bool is_reserved_key(int c)
257 {
258 switch(c)
259 {
260 case KEY_ESC:
261 return true;
262 }
263 return false;
264 }
265 bool is_reserved_keycombo(int c, int modflag)
266 {
267 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
268 return true;
269 return false;
270 }
271 bool checkcheat(Cheat cheat)
272 {
273 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
274 return true; //Main key pressed
275 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
276 return true; //Alt key pressed
277 return false;
278 }
279 117 void load_default_cheatkeys()
280 {
281 117 memset(cheatkeys, 0, sizeof(cheatkeys));
282 117 cheatkeys[Cheat::Life][0] = KEY_H;
283 117 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
284 117 cheatkeys[Cheat::Magic][0] = KEY_M;
285 117 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
286 117 cheatkeys[Cheat::Rupies][0] = KEY_R;
287 117 cheatkeys[Cheat::Bombs][0] = KEY_B;
288 117 cheatkeys[Cheat::Arrows][0] = KEY_A;
289 117 cheatkeys[Cheat::Clock][0] = KEY_I;
290 117 cheatkeys[Cheat::Walls][0] = KEY_F11;
291 117 cheatkeys[Cheat::Fast][0] = KEY_Q;
292 117 cheatkeys[Cheat::Light][0] = KEY_L;
293 117 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
294 117 cheatkeys[Cheat::Kill][0] = KEY_K;
295 117 cheatkeys[Cheat::GoTo][0] = KEY_G;
296 117 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
297 117 cheatkeys[Cheat::ShowL0][0] = KEY_0;
298 117 cheatkeys[Cheat::ShowL1][0] = KEY_1;
299 117 cheatkeys[Cheat::ShowL2][0] = KEY_2;
300 117 cheatkeys[Cheat::ShowL3][0] = KEY_3;
301 117 cheatkeys[Cheat::ShowL4][0] = KEY_4;
302 117 cheatkeys[Cheat::ShowL5][0] = KEY_5;
303 117 cheatkeys[Cheat::ShowL6][0] = KEY_6;
304 117 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
305 117 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
306 117 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
307 117 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
308 117 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
309 117 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
310 117 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
311 117 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
312 117 }
313 117 void load_game_configs()
314 {
315 117 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
316 117 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
317 117 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
318 117 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
319 117 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
320 117 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
321 117 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
322 117 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
323 117 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
324 117 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
325 117 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
326 117 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
327 117 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
328 117 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
329 117 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
330
331 //cheat modifier keya
332 117 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
333 117 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
334 117 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
335 117 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
336
337 //cheat keys
338 117 load_default_cheatkeys();
339 char buf[256];
340
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 4095 times.
4212 for(size_t q = 1; q < Cheat::Last; ++q)
341 {
342
1/2
✓ Branch 0 taken 4095 times.
✗ Branch 1 not taken.
4095 if(!bindable_cheat((Cheat)q)) continue;
343 4095 std::string cheatname = cheat_to_string((Cheat)q);
344
1/2
✓ Branch 0 taken 4095 times.
✗ Branch 1 not taken.
4095 util::lowerstr(cheatname);
345 4095 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
346
1/2
✓ Branch 0 taken 4095 times.
✗ Branch 1 not taken.
4095 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
347 4095 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
348
1/2
✓ Branch 0 taken 4095 times.
✗ Branch 1 not taken.
4095 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
349 4095 }
350
351
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
352 joystick_index = 0;
353
354 117 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
355 117 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
356 117 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
357 117 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
358 117 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
359 117 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
360 117 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
361 117 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
362 117 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
363 117 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
364
365 117 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
366 117 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
367 117 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
368 117 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
369
370 117 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
371 117 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
372 117 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
373 117 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
374 117 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
375 117 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
376 117 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
377 117 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
378 117 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
379 117 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
380 117 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
381
382 117 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
383 117 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
384 117 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
385 117 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
386
387 117 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
388
389 117 digi_volume = zc_get_config(sfx_sect,"digi",248);
390 117 midi_volume = zc_get_config(sfx_sect,"midi",255);
391 117 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
392 117 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
393 117 pan_style = zc_get_config(sfx_sect,"pan",1);
394 // 1 <= zcmusic_bufsz <= 128
395 117 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
396 117 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
397 117 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
398 117 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
399 117 Maxfps = zc_get_config(cfg_sect,"maxfps",0);
400 117 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
401 117 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
402 117 SnapshotScale = zc_get_config(cfg_sect,"snapshot_scale",2);
403 117 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
404 #ifdef __EMSCRIPTEN__
405 if (em_is_mobile()) NameEntryMode = 2;
406 #endif
407 117 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
408 117 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
409 117 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
410 117 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
411 117 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
412
413 117 window_width = resx = zc_get_config(cfg_sect,"window_width",-1);
414 117 window_height = resy = zc_get_config(cfg_sect,"window_height",-1);
415 117 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
416 117 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
417 117 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
418 117 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
419 117 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
420
421 117 loadlast = zc_get_config(cfg_sect,"load_last",0);
422
423 117 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
424
425 117 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
426
427 117 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
428 117 info_opacity = zc_get_config("zc","debug_info_opacity",255);
429 #ifdef _WIN32
430 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
431 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
432 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
433 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
434
435 // This one's for Aero
436 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
437
438 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
439 #else //UNIX
440 117 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
441 117 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
442 117 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
443 #endif
444 117 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
445 117 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
446
447 117 strcpy(qstdir,zc_get_config(cfg_sect,"quest_dir","quests"));
448 117 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
449 117 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
450 117 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
451 117 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
452 117 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
453 117 heart_beep = zc_get_config(cfg_sect,"heart_beep",0)!=0;
454 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
455 117 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
456 117 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
457 117 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
458 117 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
459 117 }
460
461 void save_control_configs(bool kb)
462 {
463 if(kb)
464 {
465 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
466 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
467 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
468 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
469
470 if (!replay_is_replaying())
471 {
472 zc_set_config(ctrl_sect,"key_a",Akey);
473 zc_set_config(ctrl_sect,"key_b",Bkey);
474 zc_set_config(ctrl_sect,"key_s",Skey);
475 zc_set_config(ctrl_sect,"key_l",Lkey);
476 zc_set_config(ctrl_sect,"key_r",Rkey);
477 zc_set_config(ctrl_sect,"key_p",Pkey);
478 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
479 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
480 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
481 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
482 zc_set_config(ctrl_sect,"key_up", DUkey);
483 zc_set_config(ctrl_sect,"key_down", DDkey);
484 zc_set_config(ctrl_sect,"key_left", DLkey);
485 zc_set_config(ctrl_sect,"key_right",DRkey);
486 }
487 }
488 else
489 {
490 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
491 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
492 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
493 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
494 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
495 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
496 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
497 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
498 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
499 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
500 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
501 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
502 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
503 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
504
505 zc_set_config(ctrl_sect,"btn_a",Abtn);
506 zc_set_config(ctrl_sect,"btn_b",Bbtn);
507 zc_set_config(ctrl_sect,"btn_s",Sbtn);
508 zc_set_config(ctrl_sect,"btn_m",Mbtn);
509 zc_set_config(ctrl_sect,"btn_l",Lbtn);
510 zc_set_config(ctrl_sect,"btn_r",Rbtn);
511 zc_set_config(ctrl_sect,"btn_p",Pbtn);
512 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
513 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
514 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
515 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
516
517 zc_set_config(ctrl_sect,"btn_up",DUbtn);
518 zc_set_config(ctrl_sect,"btn_down",DDbtn);
519 zc_set_config(ctrl_sect,"btn_left",DLbtn);
520 zc_set_config(ctrl_sect,"btn_right",DRbtn);
521 }
522 }
523
524 void save_cheatkeys()
525 {
526 char buf[256];
527 for(size_t q = 1; q < Cheat::Last; ++q)
528 {
529 if(!bindable_cheat((Cheat)q)) continue;
530 std::string cheatname = cheat_to_string((Cheat)q);
531 util::lowerstr(cheatname);
532 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
533 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
534 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
535 if(cheatkeys[q][1])
536 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
537 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
538 }
539 }
540
541 void save_game_configs()
542 {
543 packfile_password("");
544
545 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
546
547 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
548 {
549 int o_window_x, o_window_y;
550 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
551 zc_set_config(cfg_sect,"window_x",o_window_x);
552 zc_set_config(cfg_sect,"window_y",o_window_y);
553 }
554
555 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
556 {
557 window_width = al_get_display_width(all_get_display());
558 window_height = al_get_display_height(all_get_display());
559 zc_set_config(cfg_sect,"window_width",window_width);
560 zc_set_config(cfg_sect,"window_height",window_height);
561 }
562
563 zc_set_config(cfg_sect,"load_last",loadlast);
564 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
565
566 flush_config_file();
567 #ifdef __EMSCRIPTEN__
568 em_sync_fs();
569 #endif
570 }
571
572 //----------------------------------------------------------------
573
574 // Timers
575
576 30875 void fps_callback()
577 {
578 30875 lastfps=framecnt;
579 30875 framecnt=0;
580 30875 }
581
582 END_OF_FUNCTION(fps_callback)
583
584 117 int32_t Z_init_timers()
585 {
586 static bool didit = false;
587 const static char *err_str = "Couldn't allocate timer";
588 117 err_str = err_str; //Unused variable warning
589
590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if(didit)
591 return 1;
592
593 117 didit = true;
594
595 LOCK_VARIABLE(lastfps);
596 LOCK_VARIABLE(framecnt);
597 LOCK_FUNCTION(fps_callback);
598
599
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
600 return 0;
601
602 117 return 1;
603 117 }
604
605 void Z_remove_timers()
606 {
607 remove_int(fps_callback);
608 }
609
610 //----------------------------------------------------------------
611
612 void go()
613 {
614 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
615 }
616
617 void comeback()
618 {
619 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
620 }
621
622 void dump_pal(BITMAP *dest)
623 {
624 for(int32_t i=0; i<256; i++)
625 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
626 }
627
628 //----------------------------------------------------------------
629
630 int game_mouse_index = ZCM_BLANK;
631 static bool system_mouse = false;
632 28 bool sys_mouse()
633 {
634 28 system_mouse = true;
635 28 return MouseSprite::set(ZCM_NORMAL);
636 }
637 561 bool game_mouse()
638 {
639 561 system_mouse = false;
640 561 return MouseSprite::set(game_mouse_index);
641 }
642 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
643 {
644 if(!bmp)
645 return;
646 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
647 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
648 if(bmp->w == scaledw && bmp->h == scaledh)
649 user_scale = false;
650 if(user_scale || sys_recolor)
651 {
652 if(!user_scale) scale = 1;
653 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
654 if(user_scale)
655 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
656 else
657 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
658 if(sys_recolor)
659 recolor_mouse(tmpbmp);
660 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
661 destroy_bitmap(tmpbmp);
662 }
663 else
664 {
665 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
666 }
667 }
668
669 //Handles converting the mouse sprite from the .dat file
670 void recolor_mouse(BITMAP* bmp)
671 {
672 for(int32_t x = 0; x < bmp->w; ++x)
673 {
674 for(int32_t y = 0; y < bmp->h; ++y)
675 {
676 int32_t color = getpixel(bmp, x, y);
677 switch(color)
678 {
679 case dvc(1):
680 color = jwin_pal[jcCURSORMISC];
681 break;
682 case dvc(2):
683 color = jwin_pal[jcCURSOROUTLINE];
684 break;
685 case dvc(3):
686 color = jwin_pal[jcCURSORLIGHT];
687 break;
688 case dvc(5):
689 color = jwin_pal[jcCURSORDARK];
690 break;
691 default:
692 continue;
693 }
694 putpixel(bmp, x, y, color);
695 }
696 }
697 }
698 void load_mouse()
699 {
700 PALETTE pal;
701 BITMAP* cursor_bitmap = load_bitmap("assets/cursor.bmp", pal);
702 if (!cursor_bitmap)
703 Z_error_fatal("Missing required file %s\n", "assets/cursor.bmp");
704
705 enter_sys_pal();
706 MouseSprite::set(-1);
707 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
708 int32_t sz = 16*scale;
709 for(int32_t j = 0; j < 1; ++j)
710 {
711 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
712 if(zcmouse[j])
713 destroy_bitmap(zcmouse[j]);
714 zcmouse[j] = create_bitmap_ex(8,sz,sz);
715 clear_bitmap(zcmouse[j]);
716 clear_bitmap(tmpbmp);
717 blit(cursor_bitmap,tmpbmp,1,j*17+1,0,0,16,16);
718 recolor_mouse(tmpbmp);
719 if(sz!=16)
720 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
721 else
722 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
723 destroy_bitmap(tmpbmp);
724 }
725 if(!hw_palette) hw_palette = &RAMpal;
726 zc_set_palette(*hw_palette);
727
728 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
729 clear_bitmap(blankmouse);
730
731 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
732 MouseSprite::assign(ZCM_BLANK, blankmouse);
733 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
734
735 //Reload the mouse
736 if(system_mouse)
737 sys_mouse();
738 else game_mouse();
739
740 destroy_bitmap(blankmouse);
741 destroy_bitmap(cursor_bitmap);
742 exit_sys_pal();
743 }
744
745 // sets the video mode and initializes the palette and mouse sprite
746 117 bool game_vid_mode(int32_t mode,int32_t wait)
747 {
748
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if (is_headless())
749 117 return true;
750
751 extern int zq_screen_w, zq_screen_h;
752 if(set_gfx_mode(mode,resx,resy,zq_screen_w,zq_screen_h)!=0)
753 {
754 return false;
755 }
756
757 scrx = (resx-320)>>1;
758 scry = (resy-240)>>1;
759 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
760 zcmouse[q] = NULL;
761 load_mouse();
762
763 for(int32_t i=240; i<256; i++)
764 RAMpal[i]=pal_gui[i];
765
766 zc_set_palette(RAMpal);
767 clear_to_color(screen,BLACK);
768
769 rest(wait);
770 return true;
771 117 }
772
773 8 void null_quest()
774 {
775 char qstdat_string[2048];
776 8 strcpy(qstdat_string, "modules/classic/default.qst");
777
778 #ifdef __EMSCRIPTEN__
779 // The quest template data file is not included because it's really big and isn't really needed
780 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
781 // which is much smaller.
782 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
783 #endif
784
785 8 byte skip_flags[4] = { 0 };
786
787 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
788 8 }
789
790 8 void init_NES_mode()
791 {
792 8 null_quest();
793 8 }
794
795 //----------------------------------------------------------------
796
797 qword trianglelines[16]=
798 {
799 0x0000000000000000ULL,
800 0xFD00000000000000ULL,
801 0xFDFD000000000000ULL,
802 0xFDFDFD0000000000ULL,
803 0xFDFDFDFD00000000ULL,
804 0xFDFDFDFDFD000000ULL,
805 0xFDFDFDFDFDFD0000ULL,
806 0xFDFDFDFDFDFDFD00ULL,
807 0xFDFDFDFDFDFDFDFDULL,
808 0x00FDFDFDFDFDFDFDULL,
809 0x0000FDFDFDFDFDFDULL,
810 0x000000FDFDFDFDFDULL,
811 0x00000000FDFDFDFDULL,
812 0x0000000000FDFDFDULL,
813 0x000000000000FDFDULL,
814 0x00000000000000FDULL,
815 };
816
817 word screen_triangles[28][32];
818 /*
819 qword triangles[4][16]= //[direction][value]
820 {
821 {
822 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
823 },
824 {
825 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
826 },
827 {
828 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
829 },
830 {
831 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
832 }
833 };
834 */
835
836
837 /*
838 byte triangles[4][16][8]= //[direction][value][line]
839 {
840 {
841 {
842 0, 0, 0, 0, 0, 0, 0, 0
843 },
844 {
845 1, 0, 0, 0, 0, 0, 0, 0
846 },
847 {
848 2, 1, 0, 0, 0, 0, 0, 0
849 },
850 {
851 3, 2, 1, 0, 0, 0, 0, 0
852 },
853 {
854 4, 3, 2, 1, 0, 0, 0, 0
855 },
856 {
857 5, 4, 3, 2, 1, 0, 0, 0
858 },
859 {
860 6, 5, 4, 3, 2, 1, 0, 0
861 },
862 {
863 7, 6, 5, 4, 3, 2, 1, 0
864 },
865 {
866 8, 7, 6, 5, 4, 3, 2, 1
867 },
868 {
869 8, 8, 7, 6, 5, 4, 3, 2
870 },
871 {
872 8, 8, 8, 7, 6, 5, 4, 3
873 },
874 {
875 8, 8, 8, 8, 7, 6, 5, 4
876 },
877 {
878 8, 8, 8, 8, 8, 7, 6, 5
879 },
880 {
881 8, 8, 8, 8, 8, 8, 7, 6
882 },
883 {
884 8, 8, 8, 8, 8, 8, 8, 7
885 },
886 {
887 8, 8, 8, 8, 8, 8, 8, 8
888 }
889 },
890 {
891 {
892 0, 0, 0, 0, 0, 0, 0, 0
893 },
894 {
895 15, 0, 0, 0, 0, 0, 0, 0
896 },
897 {
898 14, 15, 0, 0, 0, 0, 0, 0
899 },
900 {
901 13, 14, 15, 0, 0, 0, 0, 0
902 },
903 {
904 12, 13, 14, 15, 0, 0, 0, 0
905 },
906 {
907 11, 12, 13, 14, 15, 0, 0, 0
908 },
909 {
910 10, 11, 12, 13, 14, 15, 0, 0
911 },
912 {
913 9, 10, 11, 12, 13, 14, 15, 0
914 },
915 {
916 8, 9, 10, 11, 12, 13, 14, 15
917 },
918 {
919 8, 8, 9, 10, 11, 12, 13, 14
920 },
921 {
922 8, 8, 8, 9, 10, 11, 12, 13
923 },
924 {
925 8, 8, 8, 8, 9, 10, 11, 12
926 },
927 {
928 8, 8, 8, 8, 8, 9, 10, 11
929 },
930 {
931 8, 8, 8, 8, 8, 8, 9, 10
932 },
933 {
934 8, 8, 8, 8, 8, 8, 8, 9
935 },
936 {
937 8, 8, 8, 8, 8, 8, 8, 8
938 }
939 },
940 {
941 {
942 0, 0, 0, 0, 0, 0, 0, 0
943 },
944 {
945 0, 0, 0, 0, 0, 0, 0, 1
946 },
947 {
948 0, 0, 0, 0, 0, 0, 1, 2
949 },
950 {
951 0, 0, 0, 0, 0, 1, 2, 3
952 },
953 {
954 0, 0, 0, 0, 1, 2, 3, 4
955 },
956 {
957 0, 0, 0, 1, 2, 3, 4, 5
958 },
959 {
960 0, 0, 1, 2, 3, 4, 5, 6
961 },
962 {
963 0, 1, 2, 3, 4, 5, 6, 7
964 },
965 {
966 1, 2, 3, 4, 5, 6, 7, 8
967 },
968 {
969 2, 3, 4, 5, 6, 7, 8, 8
970 },
971 {
972 3, 4, 5, 6, 7, 8, 8, 8
973 },
974 {
975 4, 5, 6, 7, 8, 8, 8, 8
976 },
977 {
978 5, 6, 7, 8, 8, 8, 8, 8
979 },
980 {
981 6, 7, 8, 8, 8, 8, 8, 8
982 },
983 {
984 7, 8, 8, 8, 8, 8, 8, 8
985 },
986 {
987 8, 8, 8, 8, 8, 8, 8, 8
988 }
989 },
990 {
991 {
992 0, 0, 0, 0, 0, 0, 0, 0
993 },
994 {
995 0, 0, 0, 0, 0, 0, 0, 15
996 },
997 {
998 0, 0, 0, 0, 0, 0, 15, 14
999 },
1000 {
1001 0, 0, 0, 0, 0, 15, 14, 13
1002 },
1003 {
1004 0, 0, 0, 0, 15, 14, 13, 12
1005 },
1006 {
1007 0, 0, 0, 15, 14, 13, 12, 11
1008 },
1009 {
1010 0, 0, 15, 14, 13, 12, 11, 10
1011 },
1012 {
1013 0, 15, 14, 13, 12, 11, 10, 9
1014 },
1015 {
1016 15, 14, 13, 12, 11, 10, 9, 8
1017 },
1018 {
1019 14, 13, 12, 11, 10, 9, 8, 8
1020 },
1021 {
1022 13, 12, 11, 10, 9, 8, 8, 8
1023 },
1024 {
1025 12, 11, 10, 9, 8, 8, 8, 8
1026 },
1027 {
1028 11, 10, 9, 8, 8, 8, 8, 8
1029 },
1030 {
1031 10, 9, 8, 8, 8, 8, 8, 8
1032 },
1033 {
1034 9, 8, 8, 8, 8, 8, 8, 8
1035 },
1036 {
1037 8, 8, 8, 8, 8, 8, 8, 8
1038 }
1039 }
1040 };
1041 */
1042
1043
1044
1045 /*
1046 for (int32_t blockrow=0; blockrow<30; ++i)
1047 {
1048 for (int32_t linerow=0; linerow<8; ++i)
1049 {
1050 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1051 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1052 {
1053 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1054 ++triangleline;
1055 }
1056 }
1057 }
1058 */
1059
1060 // the ULL suffixes are to prevent this warning:
1061 // warning: integer constant is too large for "int32_t" type
1062
1063 qword triangles[4][16][8]= //[direction][value][line]
1064 {
1065 {
1066 {
1067 0x0000000000000000ULL,
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL
1075 },
1076 {
1077 0xFD00000000000000ULL,
1078 0x0000000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL
1085 },
1086 {
1087 0xFDFD000000000000ULL,
1088 0xFD00000000000000ULL,
1089 0x0000000000000000ULL,
1090 0x0000000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL
1095 },
1096 {
1097 0xFDFDFD0000000000ULL,
1098 0xFDFD000000000000ULL,
1099 0xFD00000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL
1105 },
1106 {
1107 0xFDFDFDFD00000000ULL,
1108 0xFDFDFD0000000000ULL,
1109 0xFDFD000000000000ULL,
1110 0xFD00000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL
1115 },
1116 {
1117 0xFDFDFDFDFD000000ULL,
1118 0xFDFDFDFD00000000ULL,
1119 0xFDFDFD0000000000ULL,
1120 0xFDFD000000000000ULL,
1121 0xFD00000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL
1125 },
1126 {
1127 0xFDFDFDFDFDFD0000ULL,
1128 0xFDFDFDFDFD000000ULL,
1129 0xFDFDFDFD00000000ULL,
1130 0xFDFDFD0000000000ULL,
1131 0xFDFD000000000000ULL,
1132 0xFD00000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL
1135 },
1136 {
1137 0xFDFDFDFDFDFDFD00ULL,
1138 0xFDFDFDFDFDFD0000ULL,
1139 0xFDFDFDFDFD000000ULL,
1140 0xFDFDFDFD00000000ULL,
1141 0xFDFDFD0000000000ULL,
1142 0xFDFD000000000000ULL,
1143 0xFD00000000000000ULL,
1144 0x0000000000000000ULL
1145 },
1146 {
1147 0xFDFDFDFDFDFDFDFDULL,
1148 0xFDFDFDFDFDFDFD00ULL,
1149 0xFDFDFDFDFDFD0000ULL,
1150 0xFDFDFDFDFD000000ULL,
1151 0xFDFDFDFD00000000ULL,
1152 0xFDFDFD0000000000ULL,
1153 0xFDFD000000000000ULL,
1154 0xFD00000000000000ULL
1155 },
1156 {
1157 0xFDFDFDFDFDFDFDFDULL,
1158 0xFDFDFDFDFDFDFDFDULL,
1159 0xFDFDFDFDFDFDFD00ULL,
1160 0xFDFDFDFDFDFD0000ULL,
1161 0xFDFDFDFDFD000000ULL,
1162 0xFDFDFDFD00000000ULL,
1163 0xFDFDFD0000000000ULL,
1164 0xFDFD000000000000ULL
1165 },
1166 {
1167 0xFDFDFDFDFDFDFDFDULL,
1168 0xFDFDFDFDFDFDFDFDULL,
1169 0xFDFDFDFDFDFDFDFDULL,
1170 0xFDFDFDFDFDFDFD00ULL,
1171 0xFDFDFDFDFDFD0000ULL,
1172 0xFDFDFDFDFD000000ULL,
1173 0xFDFDFDFD00000000ULL,
1174 0xFDFDFD0000000000ULL
1175 },
1176 {
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFD00ULL,
1182 0xFDFDFDFDFDFD0000ULL,
1183 0xFDFDFDFDFD000000ULL,
1184 0xFDFDFDFD00000000ULL
1185 },
1186 {
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFD00ULL,
1193 0xFDFDFDFDFDFD0000ULL,
1194 0xFDFDFDFDFD000000ULL
1195 },
1196 {
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFD00ULL,
1204 0xFDFDFDFDFDFD0000ULL
1205 },
1206 {
1207 0xFDFDFDFDFDFDFDFDULL,
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFD00ULL
1215 },
1216 {
1217 0xFDFDFDFDFDFDFDFDULL,
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL
1225 }
1226 },
1227 {
1228 {
1229 0x0000000000000000ULL,
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL
1237 },
1238 {
1239 0x00000000000000FDULL,
1240 0x0000000000000000ULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL
1247 },
1248 {
1249 0x000000000000FDFDULL,
1250 0x00000000000000FDULL,
1251 0x0000000000000000ULL,
1252 0x0000000000000000ULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL
1257 },
1258 {
1259 0x0000000000FDFDFDULL,
1260 0x000000000000FDFDULL,
1261 0x00000000000000FDULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL
1267 },
1268 {
1269 0x00000000FDFDFDFDULL,
1270 0x0000000000FDFDFDULL,
1271 0x000000000000FDFDULL,
1272 0x00000000000000FDULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL
1277 },
1278 {
1279 0x000000FDFDFDFDFDULL,
1280 0x00000000FDFDFDFDULL,
1281 0x0000000000FDFDFDULL,
1282 0x000000000000FDFDULL,
1283 0x00000000000000FDULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL
1287 },
1288 {
1289 0x0000FDFDFDFDFDFDULL,
1290 0x000000FDFDFDFDFDULL,
1291 0x00000000FDFDFDFDULL,
1292 0x0000000000FDFDFDULL,
1293 0x000000000000FDFDULL,
1294 0x00000000000000FDULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL
1297 },
1298 {
1299 0x00FDFDFDFDFDFDFDULL,
1300 0x0000FDFDFDFDFDFDULL,
1301 0x000000FDFDFDFDFDULL,
1302 0x00000000FDFDFDFDULL,
1303 0x0000000000FDFDFDULL,
1304 0x000000000000FDFDULL,
1305 0x00000000000000FDULL,
1306 0x0000000000000000ULL
1307 },
1308 {
1309 0xFDFDFDFDFDFDFDFDULL,
1310 0x00FDFDFDFDFDFDFDULL,
1311 0x0000FDFDFDFDFDFDULL,
1312 0x000000FDFDFDFDFDULL,
1313 0x00000000FDFDFDFDULL,
1314 0x0000000000FDFDFDULL,
1315 0x000000000000FDFDULL,
1316 0x00000000000000FDULL
1317 },
1318 {
1319 0xFDFDFDFDFDFDFDFDULL,
1320 0xFDFDFDFDFDFDFDFDULL,
1321 0x00FDFDFDFDFDFDFDULL,
1322 0x0000FDFDFDFDFDFDULL,
1323 0x000000FDFDFDFDFDULL,
1324 0x00000000FDFDFDFDULL,
1325 0x0000000000FDFDFDULL,
1326 0x000000000000FDFDULL
1327 },
1328 {
1329 0xFDFDFDFDFDFDFDFDULL,
1330 0xFDFDFDFDFDFDFDFDULL,
1331 0xFDFDFDFDFDFDFDFDULL,
1332 0x00FDFDFDFDFDFDFDULL,
1333 0x0000FDFDFDFDFDFDULL,
1334 0x000000FDFDFDFDFDULL,
1335 0x00000000FDFDFDFDULL,
1336 0x0000000000FDFDFDULL
1337 },
1338 {
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0x00FDFDFDFDFDFDFDULL,
1344 0x0000FDFDFDFDFDFDULL,
1345 0x000000FDFDFDFDFDULL,
1346 0x00000000FDFDFDFDULL
1347 },
1348 {
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0x00FDFDFDFDFDFDFDULL,
1355 0x0000FDFDFDFDFDFDULL,
1356 0x000000FDFDFDFDFDULL
1357 },
1358 {
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0x00FDFDFDFDFDFDFDULL,
1366 0x0000FDFDFDFDFDFDULL
1367 },
1368 {
1369 0xFDFDFDFDFDFDFDFDULL,
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0x00FDFDFDFDFDFDFDULL
1377 },
1378 {
1379 0xFDFDFDFDFDFDFDFDULL,
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL
1387 }
1388 },
1389 {
1390 {
1391 0x0000000000000000ULL,
1392 0x0000000000000000ULL,
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL
1399 },
1400 {
1401 0x0000000000000000ULL,
1402 0x0000000000000000ULL,
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0x0000000000000000ULL,
1408 0xFD00000000000000ULL
1409 },
1410 {
1411 0x0000000000000000ULL,
1412 0x0000000000000000ULL,
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0xFD00000000000000ULL,
1418 0xFDFD000000000000ULL
1419 },
1420 {
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0xFD00000000000000ULL,
1427 0xFDFD000000000000ULL,
1428 0xFDFDFD0000000000ULL
1429 },
1430 {
1431 0x0000000000000000ULL,
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0xFD00000000000000ULL,
1436 0xFDFD000000000000ULL,
1437 0xFDFDFD0000000000ULL,
1438 0xFDFDFDFD00000000ULL
1439 },
1440 {
1441 0x0000000000000000ULL,
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0xFD00000000000000ULL,
1445 0xFDFD000000000000ULL,
1446 0xFDFDFD0000000000ULL,
1447 0xFDFDFDFD00000000ULL,
1448 0xFDFDFDFDFD000000ULL
1449 },
1450 {
1451 0x0000000000000000ULL,
1452 0x0000000000000000ULL,
1453 0xFD00000000000000ULL,
1454 0xFDFD000000000000ULL,
1455 0xFDFDFD0000000000ULL,
1456 0xFDFDFDFD00000000ULL,
1457 0xFDFDFDFDFD000000ULL,
1458 0xFDFDFDFDFDFD0000ULL
1459 },
1460 {
1461 0x0000000000000000ULL,
1462 0xFD00000000000000ULL,
1463 0xFDFD000000000000ULL,
1464 0xFDFDFD0000000000ULL,
1465 0xFDFDFDFD00000000ULL,
1466 0xFDFDFDFDFD000000ULL,
1467 0xFDFDFDFDFDFD0000ULL,
1468 0xFDFDFDFDFDFDFD00ULL
1469 },
1470 {
1471 0xFD00000000000000ULL,
1472 0xFDFD000000000000ULL,
1473 0xFDFDFD0000000000ULL,
1474 0xFDFDFDFD00000000ULL,
1475 0xFDFDFDFDFD000000ULL,
1476 0xFDFDFDFDFDFD0000ULL,
1477 0xFDFDFDFDFDFDFD00ULL,
1478 0xFDFDFDFDFDFDFDFDULL
1479 },
1480 {
1481 0xFDFD000000000000ULL,
1482 0xFDFDFD0000000000ULL,
1483 0xFDFDFDFD00000000ULL,
1484 0xFDFDFDFDFD000000ULL,
1485 0xFDFDFDFDFDFD0000ULL,
1486 0xFDFDFDFDFDFDFD00ULL,
1487 0xFDFDFDFDFDFDFDFDULL,
1488 0xFDFDFDFDFDFDFDFDULL
1489 },
1490 {
1491 0xFDFDFD0000000000ULL,
1492 0xFDFDFDFD00000000ULL,
1493 0xFDFDFDFDFD000000ULL,
1494 0xFDFDFDFDFDFD0000ULL,
1495 0xFDFDFDFDFDFDFD00ULL,
1496 0xFDFDFDFDFDFDFDFDULL,
1497 0xFDFDFDFDFDFDFDFDULL,
1498 0xFDFDFDFDFDFDFDFDULL
1499 },
1500 {
1501 0xFDFDFDFD00000000ULL,
1502 0xFDFDFDFDFD000000ULL,
1503 0xFDFDFDFDFDFD0000ULL,
1504 0xFDFDFDFDFDFDFD00ULL,
1505 0xFDFDFDFDFDFDFDFDULL,
1506 0xFDFDFDFDFDFDFDFDULL,
1507 0xFDFDFDFDFDFDFDFDULL,
1508 0xFDFDFDFDFDFDFDFDULL
1509 },
1510 {
1511 0xFDFDFDFDFD000000ULL,
1512 0xFDFDFDFDFDFD0000ULL,
1513 0xFDFDFDFDFDFDFD00ULL,
1514 0xFDFDFDFDFDFDFDFDULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL
1519 },
1520 {
1521 0xFDFDFDFDFDFD0000ULL,
1522 0xFDFDFDFDFDFDFD00ULL,
1523 0xFDFDFDFDFDFDFDFDULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL
1529 },
1530 {
1531 0xFDFDFDFDFDFDFD00ULL,
1532 0xFDFDFDFDFDFDFDFDULL,
1533 0xFDFDFDFDFDFDFDFDULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL
1539 },
1540 {
1541 0xFDFDFDFDFDFDFDFDULL,
1542 0xFDFDFDFDFDFDFDFDULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL
1549 }
1550 },
1551 {
1552 {
1553 0x0000000000000000ULL,
1554 0x0000000000000000ULL,
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL
1561 },
1562 {
1563 0x0000000000000000ULL,
1564 0x0000000000000000ULL,
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x0000000000000000ULL,
1570 0x00000000000000FDULL
1571 },
1572 {
1573 0x0000000000000000ULL,
1574 0x0000000000000000ULL,
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x00000000000000FDULL,
1580 0x000000000000FDFDULL
1581 },
1582 {
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x00000000000000FDULL,
1589 0x000000000000FDFDULL,
1590 0x0000000000FDFDFDULL
1591 },
1592 {
1593 0x0000000000000000ULL,
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x00000000000000FDULL,
1598 0x000000000000FDFDULL,
1599 0x0000000000FDFDFDULL,
1600 0x00000000FDFDFDFDULL
1601 },
1602 {
1603 0x0000000000000000ULL,
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x00000000000000FDULL,
1607 0x000000000000FDFDULL,
1608 0x0000000000FDFDFDULL,
1609 0x00000000FDFDFDFDULL,
1610 0x000000FDFDFDFDFDULL
1611 },
1612 {
1613 0x0000000000000000ULL,
1614 0x0000000000000000ULL,
1615 0x00000000000000FDULL,
1616 0x000000000000FDFDULL,
1617 0x0000000000FDFDFDULL,
1618 0x00000000FDFDFDFDULL,
1619 0x000000FDFDFDFDFDULL,
1620 0x0000FDFDFDFDFDFDULL
1621 },
1622 {
1623 0x0000000000000000ULL,
1624 0x00000000000000FDULL,
1625 0x000000000000FDFDULL,
1626 0x0000000000FDFDFDULL,
1627 0x00000000FDFDFDFDULL,
1628 0x000000FDFDFDFDFDULL,
1629 0x0000FDFDFDFDFDFDULL,
1630 0x00FDFDFDFDFDFDFDULL
1631 },
1632 {
1633 0x00000000000000FDULL,
1634 0x000000000000FDFDULL,
1635 0x0000000000FDFDFDULL,
1636 0x00000000FDFDFDFDULL,
1637 0x000000FDFDFDFDFDULL,
1638 0x0000FDFDFDFDFDFDULL,
1639 0x00FDFDFDFDFDFDFDULL,
1640 0xFDFDFDFDFDFDFDFDULL
1641 },
1642 {
1643 0x000000000000FDFDULL,
1644 0x0000000000FDFDFDULL,
1645 0x00000000FDFDFDFDULL,
1646 0x000000FDFDFDFDFDULL,
1647 0x0000FDFDFDFDFDFDULL,
1648 0x00FDFDFDFDFDFDFDULL,
1649 0xFDFDFDFDFDFDFDFDULL,
1650 0xFDFDFDFDFDFDFDFDULL
1651 },
1652 {
1653 0x0000000000FDFDFDULL,
1654 0x00000000FDFDFDFDULL,
1655 0x000000FDFDFDFDFDULL,
1656 0x0000FDFDFDFDFDFDULL,
1657 0x00FDFDFDFDFDFDFDULL,
1658 0xFDFDFDFDFDFDFDFDULL,
1659 0xFDFDFDFDFDFDFDFDULL,
1660 0xFDFDFDFDFDFDFDFDULL
1661 },
1662 {
1663 0x00000000FDFDFDFDULL,
1664 0x000000FDFDFDFDFDULL,
1665 0x0000FDFDFDFDFDFDULL,
1666 0x00FDFDFDFDFDFDFDULL,
1667 0xFDFDFDFDFDFDFDFDULL,
1668 0xFDFDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL
1671 },
1672 {
1673 0x000000FDFDFDFDFDULL,
1674 0x0000FDFDFDFDFDFDULL,
1675 0x00FDFDFDFDFDFDFDULL,
1676 0xFDFDFDFDFDFDFDFDULL,
1677 0xFDFDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL
1681 },
1682 {
1683 0x0000FDFDFDFDFDFDULL,
1684 0x00FDFDFDFDFDFDFDULL,
1685 0xFDFDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL
1691 },
1692 {
1693 0x00FDFDFDFDFDFDFDULL,
1694 0xFDFDFDFDFDFDFDFDULL,
1695 0xFDFDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL
1701 },
1702 {
1703 0xFDFDFDFDFDFDFDFDULL,
1704 0xFDFDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL
1711 }
1712 }
1713 };
1714
1715 int32_t black_opening_count=0;
1716 int32_t black_opening_x,black_opening_y;
1717 int32_t black_opening_shape;
1718
1719 1508 int32_t choose_opening_shape()
1720 {
1721 // First, count how many bits are set
1722 1508 int32_t numBits=0;
1723 int32_t bitCounter;
1724
1725
2/2
✓ Branch 0 taken 7540 times.
✓ Branch 1 taken 1508 times.
9048 for(int32_t i=0; i<bosMAX; i++)
1726 {
1727
2/2
✓ Branch 0 taken 5816 times.
✓ Branch 1 taken 1724 times.
7540 if(COOLSCROLL&(1<<i))
1728 1724 numBits++;
1729 7540 }
1730
1731 // Shouldn't happen...
1732
1/2
✓ Branch 0 taken 1508 times.
✗ Branch 1 not taken.
1508 if(numBits==0)
1733 return bosCIRCLE;
1734
1735 // Pick a bit
1736 1508 bitCounter=zc_rand()%numBits+1;
1737
1738
2/2
✓ Branch 0 taken 1993 times.
✓ Branch 1 taken 26 times.
2019 for(int32_t i=0; i<bosMAX; i++)
1739 {
1740 // If this bit is set, decrement the bit counter
1741
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 1638 times.
1993 if(COOLSCROLL&(1<<i))
1742 1638 bitCounter--;
1743
1744 // When the counter hits 0, return a value based on
1745 // which bit it stopped on.
1746 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1747
2/2
✓ Branch 0 taken 1482 times.
✓ Branch 1 taken 511 times.
1993 if(bitCounter==0)
1748 1482 return i;
1749 511 }
1750
1751 // Shouldn't be necessary, but the compiler might complain, at least
1752 26 return bosCIRCLE;
1753 1508 }
1754
1755 396 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1756 {
1757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1758
1759 396 int32_t w=256, h=224;
1760 396 int32_t blockrows=28, blockcolumns=32;
1761 396 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1762
1763
2/2
✓ Branch 0 taken 11088 times.
✓ Branch 1 taken 396 times.
11484 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1764 {
1765
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 11088 times.
365904 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1766 {
1767
2/2
✓ Branch 0 taken 147229 times.
✓ Branch 1 taken 207587 times.
354816 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1768 354816 }
1769 11088 }
1770
1771 396 black_opening_count = 66;
1772 396 black_opening_x = x;
1773 396 black_opening_y = y;
1774 396 lensclk = 0;
1775 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1776
1777
1778
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(black_opening_shape == bosFADEBLACK)
1779 {
1780 refreshTints();
1781 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1782 }
1783
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(wait)
1784 {
1785 FFCore.warpScriptCheck();
1786 for(int32_t i=0; i<66; i++)
1787 {
1788 draw_screen(tmpscr);
1789 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1790 advanceframe(true);
1791
1792 if(Quit)
1793 {
1794 break;
1795 }
1796 }
1797 }
1798 396 }
1799
1800 1112 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1801 {
1802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1112 times.
1112 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1803
1804 1112 int32_t w=256, h=224;
1805 1112 int32_t blockrows=28, blockcolumns=32;
1806 1112 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1807
1808
2/2
✓ Branch 0 taken 31136 times.
✓ Branch 1 taken 1112 times.
32248 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1809 {
1810
2/2
✓ Branch 0 taken 996352 times.
✓ Branch 1 taken 31136 times.
1027488 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1811 {
1812
2/2
✓ Branch 0 taken 507221 times.
✓ Branch 1 taken 489131 times.
996352 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1813 996352 }
1814 31136 }
1815
1816 1112 black_opening_count = -66;
1817 1112 black_opening_x = x;
1818 1112 black_opening_y = y;
1819 1112 lensclk = 0;
1820
1/2
✓ Branch 0 taken 1112 times.
✗ Branch 1 not taken.
1112 if(black_opening_shape == bosFADEBLACK)
1821 {
1822 refreshTints();
1823 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1824 }
1825
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 913 times.
1112 if(wait)
1826 {
1827 913 FFCore.warpScriptCheck();
1828
2/2
✓ Branch 0 taken 913 times.
✓ Branch 1 taken 60258 times.
61171 for(int32_t i=0; i<66; i++)
1829 {
1830 60258 draw_screen(tmpscr);
1831 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1832 60258 advanceframe(true);
1833
1834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60258 times.
60258 if(Quit)
1835 {
1836 break;
1837 }
1838 60258 }
1839 913 }
1840 1112 }
1841
1842 99528 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1843 {
1844 99528 clear_to_color(tmp_scr,BLACK);
1845 99528 int32_t w=256, h=224;
1846
1847
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 7656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90354 times.
99528 switch(black_opening_shape)
1848 {
1849 case bosOVAL:
1850 {
1851 858 double new_w=(w/2)+abs(w/2-x);
1852 858 double new_h=(h/2)+abs(h/2-y);
1853 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1854 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1855 858 break;
1856 }
1857
1858 case bosTRIANGLE:
1859 {
1860 660 double new_w=(w/2)+abs(w/2-x);
1861 660 double new_h=(h/2)+abs(h/2-y);
1862 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1863 660 double P2= (PI/2);
1864 660 double P23=(2*PI/3);
1865 660 double P43=(4*PI/3);
1866 660 double Pa= (-4*PI*a/(3*max_a));
1867 660 double angle=P2+Pa;
1868 660 double a0=angle;
1869 660 double a2=angle+P23;
1870 660 double a4=angle+P43;
1871 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1872 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1873 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1874 0);
1875 660 break;
1876 }
1877
1878 case bosSMAS:
1879 {
1880
2/2
✓ Branch 0 taken 4158 times.
✓ Branch 1 taken 3498 times.
7656 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1881
1882
2/2
✓ Branch 0 taken 214368 times.
✓ Branch 1 taken 7656 times.
222024 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1883 {
1884
2/2
✓ Branch 0 taken 1714944 times.
✓ Branch 1 taken 214368 times.
1929312 for(int32_t linerow=0; linerow<8; ++linerow)
1885 {
1886 1714944 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1887
1888
2/2
✓ Branch 0 taken 54878208 times.
✓ Branch 1 taken 1714944 times.
56593152 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1889 {
1890 164634624 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1891
6/6
✓ Branch 0 taken 39546648 times.
✓ Branch 1 taken 15331560 times.
✓ Branch 2 taken 35934032 times.
✓ Branch 3 taken 18944176 times.
✓ Branch 4 taken 20602472 times.
✓ Branch 5 taken 15331560 times.
54878208 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1892 54878208 [linerow];
1893 54878208 ++triangleline;
1894
1895
2/2
✓ Branch 0 taken 48018432 times.
✓ Branch 1 taken 6859776 times.
54878208 if(linerow==0)
1896 {
1897 6859776 }
1898 54878208 }
1899 1714944 }
1900 214368 }
1901
1902 7656 break;
1903 }
1904
1905 case bosFADEBLACK:
1906 {
1907 if(black_opening_count<0)
1908 {
1909 black_fade(zc_min(-black_opening_count,63));
1910 }
1911 else if(black_opening_count>0)
1912 {
1913 black_fade(63-zc_max(black_opening_count-3,0));
1914 }
1915 else black_fade(0);
1916 return; //no blitting from tmp_scr!
1917 }
1918
1919 90354 case bosCIRCLE:
1920 default:
1921 {
1922 90354 double new_w=(w/2)+abs(w/2-x);
1923 90354 double new_h=(h/2)+abs(h/2-y);
1924 90354 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1925 //circlefill(tmp_scr,x,y,a<<3,0);
1926 90354 circlefill(tmp_scr,x,y,r,0);
1927 90354 break;
1928 }
1929 }
1930
1931 99528 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1932 99528 }
1933
1934
1935 void black_fade(int32_t fadeamnt)
1936 {
1937 for(int32_t i=0; i < 0xEF; i++)
1938 {
1939 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1940 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1941 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1942 }
1943
1944 refreshpal = true;
1945 }
1946
1947 //----------------------------------------------------------------
1948
1949 38831728 bool item_disabled(int32_t item) //is this item disabled?
1950 {
1951
2/2
✓ Branch 0 taken 1832457 times.
✓ Branch 1 taken 36999271 times.
38831728 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1952 }
1953
1954 7618361 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1955 {
1956
2/2
✓ Branch 0 taken 135248 times.
✓ Branch 1 taken 7483113 times.
7618361 if(current_item(item_type, true) >=item)
1957 {
1958 135248 return true;
1959 }
1960
1961 7483113 return false;
1962 7618361 }
1963
1964 25026143 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1965 {
1966
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 26467 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3220277 times.
✓ Branch 6 taken 16170214 times.
✓ Branch 7 taken 5493498 times.
✓ Branch 8 taken 115687 times.
25026143 switch(item_type)
1967 {
1968 case itype_bomb:
1969 case itype_sbomb:
1970 {
1971 int32_t itemid = getItemID(itemsbuf, item_type, it);
1972
1973 if(itemid == -1)
1974 return false;
1975
1976 return (game->get_item(itemid));
1977 }
1978
1979 case itype_clock:
1980 {
1981 26467 int32_t itemid = getItemID(itemsbuf, item_type, it);
1982
1983
2/4
✓ Branch 0 taken 26467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26467 times.
✗ Branch 3 not taken.
26467 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1984 return (game->get_item(itemid));
1985 26467 return Hero.getClock()?1:0;
1986 }
1987
1988 case itype_key:
1989 return (game->get_keys()>0);
1990
1991 case itype_magiccontainer:
1992 return (game->get_maxmagic()>=game->get_mp_per_block());
1993
1994 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1995 {
1996
2/3
✓ Branch 0 taken 280536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2939741 times.
3220277 switch(it)
1997 {
1998 case -2:
1999 {
2000 for(int32_t i=0; i<MAXLEVELS; i++)
2001 {
2002 if(game->lvlitems[i]&liTRIFORCE)
2003 {
2004 return true;
2005 }
2006 }
2007
2008 return false;
2009 }
2010
2011 case -1:
2012 2939741 return (game->lvlitems[dlevel]&liTRIFORCE);
2013
2014 default:
2015
2/4
✓ Branch 0 taken 280536 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 280536 times.
280536 if(it>=0&&it<MAXLEVELS)
2016 {
2017 280536 return (game->lvlitems[it]&liTRIFORCE);
2018 }
2019
2020 break;
2021 }
2022
2023 return 0;
2024 }
2025
2026 case itype_map: //it: -2=any, -1=current level, other=that level
2027 {
2028
2/3
✓ Branch 0 taken 402420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15767794 times.
16170214 switch(it)
2029 {
2030 case -2:
2031 {
2032 for(int32_t i=0; i<MAXLEVELS; i++)
2033 {
2034 if(game->lvlitems[i]&liMAP)
2035 {
2036 return true;
2037 }
2038 }
2039
2040 return false;
2041 }
2042
2043 case -1:
2044 15767794 return (game->lvlitems[dlevel]&liMAP)!=0;
2045
2046 default:
2047
2/4
✓ Branch 0 taken 402420 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 402420 times.
402420 if(it>=0&&it<MAXLEVELS)
2048 {
2049 402420 return (game->lvlitems[it]&liMAP)!=0;
2050 }
2051
2052 break;
2053 }
2054
2055 return 0;
2056 }
2057
2058 case itype_compass: //it: -2=any, -1=current level, other=that level
2059 {
2060
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5493498 times.
5493498 switch(it)
2061 {
2062 case -2:
2063 {
2064 for(int32_t i=0; i<MAXLEVELS; i++)
2065 {
2066 if(game->lvlitems[i]&liCOMPASS)
2067 {
2068 return true;
2069 }
2070 }
2071
2072 return false;
2073 }
2074
2075 case -1:
2076 5493498 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2077
2078 default:
2079 if(it>=0&&it<MAXLEVELS)
2080 {
2081 return (game->lvlitems[it]&liCOMPASS)!=0;
2082 }
2083
2084 break;
2085 }
2086 return 0;
2087 }
2088
2089 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2090 {
2091
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 115687 times.
115687 switch(it)
2092 {
2093 case -2:
2094 {
2095 for(int32_t i=0; i<MAXLEVELS; i++)
2096 {
2097 if(game->lvlitems[i]&liBOSSKEY)
2098 {
2099 return true;
2100 }
2101 }
2102
2103 return false;
2104 }
2105
2106 case -1:
2107 115687 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2108
2109 default:
2110 if(it>=0&&it<MAXLEVELS)
2111 {
2112 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2113 }
2114 break;
2115 }
2116 return 0;
2117 }
2118
2119 default:
2120 //it=(1<<(it-1));
2121 /*if (item_type>=itype_max)
2122 {
2123 enter_sys_pal();
2124 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2125 exit_sys_pal();
2126
2127 return false;
2128 }*/
2129 int32_t itemid = getItemID(itemsbuf, item_type, it);
2130
2131 if(itemid == -1)
2132 return false;
2133
2134 return game->get_item(itemid);
2135 }
2136 25026143 }
2137
2138
2139 51803521 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2140 {
2141
9/9
✓ Branch 0 taken 26467 times.
✓ Branch 1 taken 51591785 times.
✓ Branch 2 taken 26467 times.
✓ Branch 3 taken 26467 times.
✓ Branch 4 taken 26467 times.
✓ Branch 5 taken 26467 times.
✓ Branch 6 taken 26467 times.
✓ Branch 7 taken 26467 times.
✓ Branch 8 taken 26467 times.
51803521 switch(item_type)
2142 {
2143 case itype_clock:
2144 {
2145 26467 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2146
2147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26467 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2148 return itemsbuf[maxid].fam_type;
2149
2150 26467 return has_item(itype_clock,1) ? 1 : 0;
2151 }
2152
2153 case itype_key:
2154 26467 return game->get_keys();
2155
2156 case itype_lkey:
2157 26467 return game->lvlkeys[get_dlevel()];
2158
2159 case itype_magiccontainer:
2160 26467 return game->get_maxmagic()/game->get_mp_per_block();
2161
2162 case itype_triforcepiece:
2163 {
2164 26467 int32_t count=0;
2165
2166
2/2
✓ Branch 0 taken 13551104 times.
✓ Branch 1 taken 26467 times.
13577571 for(int32_t i=0; i<MAXLEVELS; i++)
2167 {
2168 13551104 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2169 13551104 }
2170
2171 26467 return count;
2172 }
2173
2174 case itype_map:
2175 {
2176 26467 int32_t count=0;
2177
2178
2/2
✓ Branch 0 taken 13551104 times.
✓ Branch 1 taken 26467 times.
13577571 for(int32_t i=0; i<MAXLEVELS; i++)
2179 {
2180 13551104 count+=(game->lvlitems[i]&liMAP)?1:0;
2181 13551104 }
2182
2183 26467 return count;
2184 }
2185
2186 case itype_compass:
2187 {
2188 26467 int32_t count=0;
2189
2190
2/2
✓ Branch 0 taken 13551104 times.
✓ Branch 1 taken 26467 times.
13577571 for(int32_t i=0; i<MAXLEVELS; i++)
2191 {
2192 13551104 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2193 13551104 }
2194
2195 26467 return count;
2196 }
2197
2198 case itype_bosskey:
2199 {
2200 26467 int32_t count=0;
2201
2202
2/2
✓ Branch 0 taken 13551104 times.
✓ Branch 1 taken 26467 times.
13577571 for(int32_t i=0; i<MAXLEVELS; i++)
2203 {
2204 13551104 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2205 13551104 }
2206
2207 26467 return count;
2208 }
2209
2210 default:
2211 51591785 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2212
2213
2/2
✓ Branch 0 taken 9875888 times.
✓ Branch 1 taken 41715897 times.
51591785 if(maxid == -1)
2214 41715897 return 0;
2215
2216 9875888 return itemsbuf[maxid].fam_type;
2217 }
2218 51803521 }
2219
2220 44185160 int32_t current_item(int32_t item_type) //item currently being used
2221 {
2222 44185160 return current_item(item_type, true);
2223 }
2224
2225 117 std::map<int32_t, int32_t> itemcache;
2226 117 std::map<int32_t, int32_t> itemcache_cost;
2227
2228 void removeFromItemCache(int32_t itemclass)
2229 {
2230 itemcache.erase(itemclass);
2231 itemcache_cost.erase(itemclass);
2232 cache_tile_mod_clear();
2233 }
2234
2235 5861589 void flushItemCache(bool justcost)
2236 {
2237 5861589 itemcache_cost.clear();
2238
2/2
✓ Branch 0 taken 5831552 times.
✓ Branch 1 taken 30037 times.
5861589 if(!justcost)
2239 30037 itemcache.clear();
2240
2/2
✓ Branch 0 taken 5831120 times.
✓ Branch 1 taken 432 times.
5831552 else if(replay_version_check(0,19))
2241 5831120 return;
2242
2243 30469 cache_tile_mod_clear();
2244
2245 //also fix the active subscreen if items were deleted -DD
2246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30469 times.
30469 if(game != NULL)
2247 {
2248 30469 verifyBothWeapons();
2249 30469 refresh_subscr_items();
2250 30469 }
2251 5861589 }
2252
2253 // This is used often, so it should be as direct as possible.
2254 237714092 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2255 {
2256 237714092 bool use_cost_cache = replay_version_check(19);
2257
2/2
✓ Branch 0 taken 196304690 times.
✓ Branch 1 taken 41409402 times.
237714092 if(jinx_check)
2258 {
2259
4/4
✓ Branch 0 taken 39648378 times.
✓ Branch 1 taken 1761024 times.
✓ Branch 2 taken 566304 times.
✓ Branch 3 taken 39082074 times.
41409402 if(!(HeroSwordClk() || HeroItemClk()))
2260 39082074 jinx_check = false; //not jinxed
2261 41409402 }
2262
2/2
✓ Branch 0 taken 113585 times.
✓ Branch 1 taken 237600507 times.
237714092 if(!Hero.BunnyClock())
2263 237600507 check_bunny = false; //not bunnied
2264
2/2
✓ Branch 0 taken 214190172 times.
✓ Branch 1 taken 23523920 times.
237714092 if(itemtype == itype_ring) checkmagic = true;
2265
4/4
✓ Branch 0 taken 235386764 times.
✓ Branch 1 taken 2327328 times.
✓ Branch 2 taken 211849481 times.
✓ Branch 3 taken 23242659 times.
472806232 if (!jinx_check && !check_bunny
2266
3/4
✓ Branch 0 taken 235386764 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 235092140 times.
✓ Branch 3 taken 294624 times.
235386764 && (use_cost_cache || itemtype != itype_ring))
2267 {
2268
4/4
✓ Branch 0 taken 171793023 times.
✓ Branch 1 taken 40351082 times.
✓ Branch 2 taken 171631357 times.
✓ Branch 3 taken 161666 times.
212144105 auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
2269 212144105 auto res = cache.find(itemtype);
2270
2271
2/2
✓ Branch 0 taken 196815949 times.
✓ Branch 1 taken 15328156 times.
212144105 if(res != cache.end())
2272 196815949 return res->second;
2273 15328156 }
2274
2275 40898143 int32_t result = -1;
2276 40898143 int32_t highestlevel = -1;
2277
2278
2/2
✓ Branch 0 taken 10469924608 times.
✓ Branch 1 taken 40898143 times.
10510822751 for(int32_t i=0; i<MAXITEMS; i++)
2279 {
2280
5/6
✓ Branch 0 taken 740217966 times.
✓ Branch 1 taken 9729706642 times.
✓ Branch 2 taken 16232093 times.
✓ Branch 3 taken 723985873 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16232093 times.
10469924608 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2281 {
2282
4/4
✓ Branch 0 taken 15725229 times.
✓ Branch 1 taken 506864 times.
✓ Branch 2 taken 8694 times.
✓ Branch 3 taken 15716535 times.
16232093 if(checkmagic && itemtype != itype_magicring)
2283
2/2
✓ Branch 0 taken 15716377 times.
✓ Branch 1 taken 158 times.
15716535 if(!checkmagiccost(i))
2284 158 continue;
2285
6/6
✓ Branch 0 taken 14671645 times.
✓ Branch 1 taken 1560290 times.
✓ Branch 2 taken 106359 times.
✓ Branch 3 taken 1453931 times.
✓ Branch 4 taken 863949 times.
✓ Branch 5 taken 696341 times.
16231935 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 696341 times.
696341 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2287 696341 continue;
2288
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15535594 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15535594 if(check_bunny && !checkbunny(i))
2289 continue;
2290
2291
2/2
✓ Branch 0 taken 153893 times.
✓ Branch 1 taken 15381701 times.
15535594 if(itemsbuf[i].fam_type >= highestlevel)
2292 {
2293 15381701 highestlevel = itemsbuf[i].fam_type;
2294 15381701 result=i;
2295 15381701 }
2296 15535594 }
2297 10469228109 }
2298
2299
3/4
✓ Branch 0 taken 38570815 times.
✓ Branch 1 taken 2327328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38570815 times.
40898143 if(!(jinx_check || check_bunny)) //Can't cache jinx_check/check_bunny
2300 {
2301
2/2
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 38566355 times.
38570815 if (use_cost_cache)
2302 {
2303
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 2192 times.
4460 if (!checkmagic)
2304 2192 itemcache[itemtype] = result;
2305
5/6
✓ Branch 0 taken 2192 times.
✓ Branch 1 taken 2268 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2188 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4460 if (checkmagic || result < 0 || checkmagiccost(result))
2306 4460 itemcache_cost[itemtype] = result;
2307 4460 }
2308 else
2309 {
2310 38566355 itemcache[itemtype] = result;
2311 }
2312 38570815 }
2313 40898143 return result;
2314 237714092 }
2315
2316 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2317 235830977 int32_t current_item_id(int32_t itype, bool checkmagic, bool jinx_check, bool check_bunny)
2318 {
2319
2/4
✓ Branch 0 taken 235830977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 235830977 times.
235830977 if(itype < 0 || itype >= itype_max) return -1;
2320
1/2
✓ Branch 0 taken 235830977 times.
✗ Branch 1 not taken.
235830977 if(game->OverrideItems[itype] > -2)
2321 {
2322 auto ovid = game->OverrideItems[itype];
2323 if(ovid < 0 || ovid >= MAXITEMS)
2324 return -1;
2325 if(itemsbuf[ovid].family == itype)
2326 {
2327 if(itype == itype_magicring)
2328 checkmagic = false;
2329 else if(itype == itype_ring)
2330 checkmagic = true;
2331
2332 if(checkmagic && !checkmagiccost(ovid))
2333 return -1;
2334 if(jinx_check && !(itemsbuf[ovid].flags & ITEM_JINX_IMMUNE)
2335 && (usesSwordJinx(ovid) ? HeroSwordClk() : HeroItemClk()))
2336 return -1;
2337 return ovid;
2338 }
2339 }
2340 235830977 auto ret = _c_item_id_internal(itype,checkmagic,jinx_check,check_bunny);
2341
2/2
✓ Branch 0 taken 39526287 times.
✓ Branch 1 taken 196304690 times.
235830977 if(!jinx_check) //If not already a jinx-immune-only check...
2342 {
2343 //And the player IS jinxed...
2344
4/4
✓ Branch 0 taken 194886643 times.
✓ Branch 1 taken 1418047 times.
✓ Branch 2 taken 465068 times.
✓ Branch 3 taken 194421575 times.
196304690 if(HeroSwordClk() || HeroItemClk())
2345 {
2346 //Then do a jinx-immune-only check here
2347 1883115 auto ret2 = _c_item_id_internal(itype,checkmagic,true,check_bunny);
2348 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2349 //Should NOT need a compat rule, as this should always return -1 in old quests.
2350
2/2
✓ Branch 0 taken 523197 times.
✓ Branch 1 taken 1359918 times.
1883115 if(ret2 > -1) return ret2;
2351 1359918 }
2352 195781493 }
2353 235307780 return ret;
2354 235830977 }
2355
2356 19471445 int32_t current_item_power(int32_t itemtype)
2357 {
2358 19471445 int32_t result = current_item_id(itemtype,true);
2359
2/2
✓ Branch 0 taken 14106681 times.
✓ Branch 1 taken 5364764 times.
19471445 return (result<0) ? 0 : itemsbuf[result].power;
2360 }
2361
2362 11 int32_t heart_container_id()
2363 {
2364
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 for(int32_t i=0; i<MAXITEMS; i++)
2365 {
2366
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 308 times.
319 if(itemsbuf[i].family == itype_heartcontainer)
2367 {
2368 11 return i;
2369 }
2370 308 }
2371 return -1;
2372 11 }
2373
2374 struct tilemod_cache_state_t
2375 {
2376
6/6
✓ Branch 0 taken 26147 times.
✓ Branch 1 taken 6027753 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 6027751 times.
✓ Branch 4 taken 318 times.
✓ Branch 5 taken 6027433 times.
12081653 bool operator==(const tilemod_cache_state_t&) const = default;
2377
2378 bool valid;
2379 bool bunny_clock;
2380 bool superman;
2381 int shield;
2382 };
2383 tilemod_cache_state_t tilemod_cache_state;
2384 int32_t tilemod_cache_value;
2385
2386 31001 void cache_tile_mod_clear()
2387 {
2388 31001 tilemod_cache_state = {false};
2389 31001 }
2390
2391 6053900 int32_t item_tile_mod()
2392 {
2393 24215600 tilemod_cache_state_t state = {
2394 .valid = true,
2395 6053900 .bunny_clock = Hero.BunnyClock() != 0,
2396 6053900 .superman = Hero.superman,
2397 6053900 .shield = Hero.active_shield_id,
2398 };
2399
2/2
✓ Branch 0 taken 6027433 times.
✓ Branch 1 taken 26467 times.
6053900 if (tilemod_cache_state == state)
2400 6027433 return tilemod_cache_value;
2401
2402 26467 int32_t tile=0;
2403 26467 bool check_bombcost = !get_qr(qr_BROKEN_BOMB_AMMO_COSTS);
2404
3/4
✓ Branch 0 taken 26467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21489 times.
✓ Branch 3 taken 4978 times.
26467 if(check_bombcost || game->get_bombs())
2405 {
2406 21489 int32_t itemid = current_item_id(itype_bomb,check_bombcost);
2407
3/4
✓ Branch 0 taken 20340 times.
✓ Branch 1 taken 1149 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20340 times.
21489 if(itemid > -1 && checkbunny(itemid))
2408 20340 tile+=itemsbuf[itemid].ltm;
2409 21489 }
2410
2411
3/4
✓ Branch 0 taken 26467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6765 times.
✓ Branch 3 taken 19702 times.
26467 if(check_bombcost || game->get_sbombs())
2412 {
2413 6765 int32_t itemid = current_item_id(itype_sbomb,check_bombcost);
2414
3/4
✓ Branch 0 taken 6759 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6759 times.
6765 if(itemid > -1 && checkbunny(itemid))
2415 6759 tile+=itemsbuf[itemid].ltm;
2416 6765 }
2417
2418
2/2
✓ Branch 0 taken 25610 times.
✓ Branch 1 taken 857 times.
26467 if(current_item(itype_clock))
2419 {
2420 857 int32_t itemid =
2421
1/2
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
857 get_qr(qr_HARDCODED_LITEM_LTMS)
2422 ? iClock
2423 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2424
2/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 857 times.
857 if(itemid > -1 && checkbunny(itemid))
2425 857 tile+=itemsbuf[itemid].ltm;
2426 857 }
2427
2428
2/2
✓ Branch 0 taken 20192 times.
✓ Branch 1 taken 6275 times.
26467 if(current_item(itype_key))
2429 {
2430 6275 int32_t itemid =
2431
1/2
✓ Branch 0 taken 6275 times.
✗ Branch 1 not taken.
6275 get_qr(qr_HARDCODED_LITEM_LTMS)
2432 ? iKey
2433 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2434
2/4
✓ Branch 0 taken 6275 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6275 times.
6275 if(itemid > -1 && checkbunny(itemid))
2435 6275 tile+=itemsbuf[itemid].ltm;
2436 6275 }
2437
2438
2/2
✓ Branch 0 taken 24989 times.
✓ Branch 1 taken 1478 times.
26467 if(current_item(itype_lkey))
2439 {
2440 1478 int32_t itemid =
2441
2/2
✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 6 times.
1478 get_qr(qr_HARDCODED_LITEM_LTMS)
2442 ? iLevelKey
2443 6 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2444
2/4
✓ Branch 0 taken 1478 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1478 times.
1478 if(itemid > -1 && checkbunny(itemid))
2445 1478 tile+=itemsbuf[itemid].ltm;
2446 1478 }
2447
2448
2/2
✓ Branch 0 taken 5912 times.
✓ Branch 1 taken 20555 times.
26467 if(current_item(itype_map))
2449 {
2450 20555 int32_t itemid =
2451
2/2
✓ Branch 0 taken 20553 times.
✓ Branch 1 taken 2 times.
20555 get_qr(qr_HARDCODED_LITEM_LTMS)
2452 ? iMap
2453 2 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2454
2/4
✓ Branch 0 taken 20555 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20555 times.
20555 if(itemid > -1 && checkbunny(itemid))
2455 20555 tile+=itemsbuf[itemid].ltm;
2456 20555 }
2457
2458
2/2
✓ Branch 0 taken 5698 times.
✓ Branch 1 taken 20769 times.
26467 if(current_item(itype_compass))
2459 {
2460 20769 int32_t itemid =
2461
2/2
✓ Branch 0 taken 20368 times.
✓ Branch 1 taken 401 times.
20769 get_qr(qr_HARDCODED_LITEM_LTMS)
2462 ? iCompass
2463 401 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2464
2/4
✓ Branch 0 taken 20769 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20769 times.
20769 if(itemid > -1 && checkbunny(itemid))
2465 20769 tile+=itemsbuf[itemid].ltm;
2466 20769 }
2467
2468
2/2
✓ Branch 0 taken 15499 times.
✓ Branch 1 taken 10968 times.
26467 if(current_item(itype_bosskey))
2469 {
2470 10968 int32_t itemid =
2471
1/2
✓ Branch 0 taken 10968 times.
✗ Branch 1 not taken.
10968 get_qr(qr_HARDCODED_LITEM_LTMS)
2472 ? iBossKey
2473 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2474
2/4
✓ Branch 0 taken 10968 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10968 times.
10968 if(itemid > -1 && checkbunny(itemid))
2475 10968 tile+=itemsbuf[itemid].ltm;
2476 10968 }
2477
2478
2/2
✓ Branch 0 taken 13012 times.
✓ Branch 1 taken 13455 times.
26467 if(current_item(itype_magiccontainer))
2479 {
2480 13455 int32_t itemid =
2481
2/2
✓ Branch 0 taken 13001 times.
✓ Branch 1 taken 454 times.
13455 get_qr(qr_HARDCODED_LITEM_LTMS)
2482 ? iMagicC
2483 454 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2484
3/4
✓ Branch 0 taken 13455 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 13438 times.
13455 if(itemid > -1 && checkbunny(itemid))
2485 13438 tile+=itemsbuf[itemid].ltm;
2486 13455 }
2487
2488
2/2
✓ Branch 0 taken 7161 times.
✓ Branch 1 taken 19306 times.
26467 if(current_item(itype_triforcepiece))
2489 {
2490 19306 int32_t itemid =
2491
1/2
✓ Branch 0 taken 19306 times.
✗ Branch 1 not taken.
19306 get_qr(qr_HARDCODED_LITEM_LTMS)
2492 ? iTriforce
2493 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2494
2/4
✓ Branch 0 taken 19306 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19306 times.
19306 if(itemid > -1 && checkbunny(itemid))
2495 19306 tile+=itemsbuf[itemid].ltm;
2496 19306 }
2497
2498
2/2
✓ Branch 0 taken 13551104 times.
✓ Branch 1 taken 26467 times.
13577571 for(int32_t i=0; i<itype_max; i++)
2499 {
2500
2/2
✓ Branch 0 taken 13294592 times.
✓ Branch 1 taken 256512 times.
13551104 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2501 {
2502
2/2
✓ Branch 0 taken 5010 times.
✓ Branch 1 taken 251502 times.
256512 switch(i)
2503 {
2504 case itype_bomb:
2505 case itype_sbomb:
2506 case itype_clock:
2507 case itype_key:
2508 case itype_lkey:
2509 case itype_map:
2510 case itype_compass:
2511 case itype_bosskey:
2512 case itype_magiccontainer:
2513 case itype_triforcepiece:
2514 5010 continue; //already handled
2515 }
2516 251502 }
2517 13546094 int32_t itemid = current_item_id(i,false);
2518
2/2
✓ Branch 0 taken 13519627 times.
✓ Branch 1 taken 26467 times.
13546094 if(i == itype_shield)
2519 26467 itemid = getCurrentShield(false);
2520
2521
4/4
✓ Branch 0 taken 353604 times.
✓ Branch 1 taken 13192490 times.
✓ Branch 2 taken 919 times.
✓ Branch 3 taken 352685 times.
13546094 if(itemid < 0 || !checkbunny(itemid))
2522 13193409 continue;
2523
2524 352685 itemdata const& itm = itemsbuf[itemid];
2525
2526
2/2
✓ Branch 0 taken 328767 times.
✓ Branch 1 taken 23918 times.
352685 switch(itm.family)
2527 {
2528 case itype_shield:
2529
1/2
✓ Branch 0 taken 23918 times.
✗ Branch 1 not taken.
23918 if(itm.flags & ITEM_FLAG9) //active shield
2530 {
2531 if(!usingActiveShield(itemid))
2532 {
2533 tile+=itm.misc6; //'Inactive PTM'
2534 continue;
2535 }
2536 }
2537 23918 break;
2538 }
2539
2540 352685 tile+=itm.ltm;
2541 352685 }
2542
2543 26467 tilemod_cache_value = tile;
2544 26467 tilemod_cache_state = state;
2545 26467 return tile;
2546 6053900 }
2547
2548 6053900 int32_t bunny_tile_mod()
2549 {
2550
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 6052030 times.
6053900 if(Hero.BunnyClock())
2551 {
2552 1870 return game->get_bunny_ltm();
2553 }
2554 6052030 return 0;
2555 6053900 }
2556
2557 // Hints are drawn on a separate layer to combo reveals.
2558 16332 void draw_lens_under(BITMAP *dest, bool layer)
2559 {
2560 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2561 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2562 //Lens flag 3: Don't show armos/chest/dive items
2563 //Lens flag 4: Show Raft Paths
2564 //Lens flag 5: Show Invisible Enemies
2565
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2566
2567 16332 int32_t strike_hint_table[11]=
2568 {
2569 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2570 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2571 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2572 };
2573
2574 // int32_t page = tmpscr->cpage;
2575 {
2576 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2577 // int32_t temptimer=0;
2578 16332 int32_t tempitem, tempweapon=0;
2579 16332 strike_hint=strike_hint_table[strike_hint_counter];
2580
2581
2/2
✓ Branch 0 taken 15842 times.
✓ Branch 1 taken 490 times.
16332 if(strike_hint_timer>32)
2582 {
2583 490 strike_hint_timer=0;
2584 490 strike_hint_counter=((strike_hint_counter+1)%11);
2585 490 }
2586
2587 16332 ++strike_hint_timer;
2588
2589
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2590 {
2591 2874432 int32_t x = (i & 15) << 4;
2592 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2593 2874432 int32_t tempitemx=-16, tempitemy=-16;
2594 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2595
2596
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2597 {
2598 5748864 int32_t checkflag=0;
2599
2600
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2601 {
2602 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2603 2874432 }
2604 else
2605 {
2606 2874432 checkflag=tmpscr->sflag[i];
2607 }
2608
2609
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2610 {
2611
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2612 {
2613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2614 906 }
2615 else
2616 {
2617 192 checkflag = strike_hint;
2618 }
2619 1098 }
2620
2621
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2622 {
2623 case 0:
2624 case mfZELDA:
2625 case mfPUSHED:
2626 case mfENEMY0:
2627 case mfENEMY1:
2628 case mfENEMY2:
2629 case mfENEMY3:
2630 case mfENEMY4:
2631 case mfENEMY5:
2632 case mfENEMY6:
2633 case mfENEMY7:
2634 case mfENEMY8:
2635 case mfENEMY9:
2636 case mfSINGLE:
2637 case mfSINGLE16:
2638 case mfNOENEMY:
2639 case mfTRAP_H:
2640 case mfTRAP_V:
2641 case mfTRAP_4:
2642 case mfTRAP_LR:
2643 case mfTRAP_UD:
2644 case mfNOGROUNDENEMY:
2645 case mfNOBLOCKS:
2646 case mfSCRIPT1:
2647 case mfSCRIPT2:
2648 case mfSCRIPT3:
2649 case mfSCRIPT4:
2650 case mfSCRIPT5:
2651 case mfSCRIPT6:
2652 case mfSCRIPT7:
2653 case mfSCRIPT8:
2654 case mfSCRIPT9:
2655 case mfSCRIPT10:
2656 case mfSCRIPT11:
2657 case mfSCRIPT12:
2658 case mfSCRIPT13:
2659 case mfSCRIPT14:
2660 case mfSCRIPT15:
2661 case mfSCRIPT16:
2662 case mfSCRIPT17:
2663 case mfSCRIPT18:
2664 case mfSCRIPT19:
2665 case mfSCRIPT20:
2666 case mfPITHOLE:
2667 case mfPITFALLFLOOR:
2668 case mfLAVA:
2669 case mfICE:
2670 case mfICEDAMAGE:
2671 case mfDAMAGE1:
2672 case mfDAMAGE2:
2673 case mfDAMAGE4:
2674 case mfDAMAGE8:
2675 case mfDAMAGE16:
2676 case mfDAMAGE32:
2677 case mfFREEZEALL:
2678 case mfFREZEALLANSFFCS:
2679 case mfFREEZEFFCSOLY:
2680 case mfSCRITPTW1TRIG:
2681 case mfSCRITPTW2TRIG:
2682 case mfSCRITPTW3TRIG:
2683 case mfSCRITPTW4TRIG:
2684 case mfSCRITPTW5TRIG:
2685 case mfSCRITPTW6TRIG:
2686 case mfSCRITPTW7TRIG:
2687 case mfSCRITPTW8TRIG:
2688 case mfSCRITPTW9TRIG:
2689 case mfSCRITPTW10TRIG:
2690 case mfTROWEL:
2691 case mfTROWELNEXT:
2692 case mfTROWELSPECIALITEM:
2693 case mfSLASHPOT:
2694 case mfLIFTPOT:
2695 case mfLIFTORSLASH:
2696 case mfLIFTROCK:
2697 case mfLIFTROCKHEAVY:
2698 case mfDROPITEM:
2699 case mfSPECIALITEM:
2700 case mfDROPKEY:
2701 case mfDROPLKEY:
2702 case mfDROPCOMPASS:
2703 case mfDROPMAP:
2704 case mfDROPBOSSKEY:
2705 case mfSPAWNNPC:
2706 case mfSWITCHHOOK:
2707 case mfSIDEVIEWLADDER:
2708 case mfSIDEVIEWPLATFORM:
2709 case mfNOENEMYSPAWN:
2710 case mfENEMYALL:
2711 case mfNOMIRROR:
2712 case mfUNSAFEGROUND:
2713 case mf168:
2714 case mf169:
2715 case mf170:
2716 case mf171:
2717 case mf172:
2718 case mf173:
2719 case mf174:
2720 case mf175:
2721 case mf176:
2722 case mf177:
2723 case mf178:
2724 case mf179:
2725 case mf180:
2726 case mf181:
2727 case mf182:
2728 case mf183:
2729 case mf184:
2730 case mf185:
2731 case mf186:
2732 case mf187:
2733 case mf188:
2734 case mf189:
2735 case mf190:
2736 case mf191:
2737 case mf192:
2738 case mf193:
2739 case mf194:
2740 case mf195:
2741 case mf196:
2742 case mf197:
2743 case mf198:
2744 case mf199:
2745 case mf200:
2746 case mf201:
2747 case mf202:
2748 case mf203:
2749 case mf204:
2750 case mf205:
2751 case mf206:
2752 case mf207:
2753 case mf208:
2754 case mf209:
2755 case mf210:
2756 case mf211:
2757 case mf212:
2758 case mf213:
2759 case mf214:
2760 case mf215:
2761 case mf216:
2762 case mf217:
2763 case mf218:
2764 case mf219:
2765 case mf220:
2766 case mf221:
2767 case mf222:
2768 case mf223:
2769 case mf224:
2770 case mf225:
2771 case mf226:
2772 case mf227:
2773 case mf228:
2774 case mf229:
2775 case mf230:
2776 case mf231:
2777 case mf232:
2778 case mf233:
2779 case mf234:
2780 case mf235:
2781 case mf236:
2782 case mf237:
2783 case mf238:
2784 case mf239:
2785 case mf240:
2786 case mf241:
2787 case mf242:
2788 case mf243:
2789 case mf244:
2790 case mf245:
2791 case mf246:
2792 case mf247:
2793 case mf248:
2794 case mf249:
2795 case mf250:
2796 case mf251:
2797 case mf252:
2798 case mf253:
2799 case mf254:
2800 case mfEXTENDED:
2801 5706470 break;
2802
2803 case mfPUSHUD:
2804 case mfPUSHLR:
2805 case mfPUSH4:
2806 case mfPUSHU:
2807 case mfPUSHD:
2808 case mfPUSHL:
2809 case mfPUSHR:
2810 case mfPUSHUDNS:
2811 case mfPUSHLRNS:
2812 case mfPUSH4NS:
2813 case mfPUSHUNS:
2814 case mfPUSHDNS:
2815 case mfPUSHLNS:
2816 case mfPUSHRNS:
2817 case mfPUSHUDINS:
2818 case mfPUSHLRINS:
2819 case mfPUSH4INS:
2820 case mfPUSHUINS:
2821 case mfPUSHDINS:
2822 case mfPUSHLINS:
2823 case mfPUSHRINS:
2824
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2825
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2826 {
2827 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2828 }
2829
2830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2831
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2832 {
2833
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2834 {
2835
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2836 {
2837 case cPUSH_HEAVY:
2838 case cPUSH_HW:
2839 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2840 72 tempitemx=x, tempitemy=y;
2841
2842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2843 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2844
2845 72 break;
2846
2847 case cPUSH_HEAVY2:
2848 case cPUSH_HW2:
2849 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2850 63 tempitemx=x, tempitemy=y;
2851
2852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2853 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2854
2855 63 break;
2856 }
2857 1032 }
2858 2438 }
2859
2860 3148 break;
2861
2862 case mfWHISTLE:
2863
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2864 {
2865 tempitem=getItemID(itemsbuf,itype_whistle,1);
2866
2867 if(tempitem<0) break;
2868
2869 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2870 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2871 {
2872 tempitemx=x;
2873 tempitemy=y;
2874 }
2875
2876 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2877 }
2878
2879 2418 break;
2880
2881 //Why is this here?
2882 case mfFAIRY:
2883 case mfMAGICFAIRY:
2884 case mfALLFAIRY:
2885 if(hints)
2886 {
2887 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2888
2889 if(tempitem < 0) break;
2890
2891 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2892 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2893 {
2894 tempitemx=x;
2895 tempitemy=y;
2896 }
2897
2898 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2899 }
2900
2901 break;
2902
2903 case mfANYFIRE:
2904
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2905 {
2906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2907 252 }
2908 else
2909 {
2910 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2911
2912
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2913
2914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2915
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2916 {
2917 189 tempitemx=x;
2918 189 tempitemy=y;
2919 189 }
2920
2921 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2922 }
2923
2924 504 break;
2925
2926 case mfSTRONGFIRE:
2927 if(!hints)
2928 {
2929 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2930 }
2931 else
2932 {
2933 tempitem=getItemID(itemsbuf,itype_candle,2);
2934
2935 if(tempitem<0) break;
2936
2937 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2938 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2939 {
2940 tempitemx=x;
2941 tempitemy=y;
2942 }
2943
2944 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2945 }
2946
2947 break;
2948
2949 case mfMAGICFIRE:
2950 if(!hints)
2951 {
2952 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2953 }
2954 else
2955 {
2956 tempitem=getItemID(itemsbuf,itype_wand,1);
2957
2958 if(tempitem<0) break;
2959
2960 tempweapon=wFire;
2961
2962 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2963 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2964 {
2965 tempitemx=x;
2966 tempitemy=y;
2967 }
2968 else
2969 {
2970 tempweaponx=x;
2971 tempweapony=y;
2972 }
2973
2974 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2975 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2976 }
2977
2978 break;
2979
2980 case mfDIVINEFIRE:
2981 if(!hints)
2982 {
2983 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2984 }
2985 else
2986 {
2987 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2988
2989 if(tempitem<0) break;
2990
2991 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2992 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2993 {
2994 tempitemx=x;
2995 tempitemy=y;
2996 }
2997
2998 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2999 }
3000
3001 break;
3002
3003 case mfARROW:
3004
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
3005 {
3006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
3007 732 }
3008 else
3009 {
3010 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
3011
3012
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
3013
3014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3015
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3016 {
3017 61 tempitemx=x;
3018 61 tempitemy=y;
3019 61 }
3020
3021 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3022 }
3023
3024 814 break;
3025
3026 case mfSARROW:
3027 if(!hints)
3028 {
3029 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3030 }
3031 else
3032 {
3033 tempitem=getItemID(itemsbuf,itype_arrow,2);
3034
3035 if(tempitem<0) break;
3036
3037 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3038 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3039 {
3040 tempitemx=x;
3041 tempitemy=y;
3042 }
3043
3044 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3045 }
3046
3047 break;
3048
3049 case mfGARROW:
3050 if(!hints)
3051 {
3052 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3053 }
3054 else
3055 {
3056 tempitem=getItemID(itemsbuf,itype_arrow,3);
3057
3058 if(tempitem<0) break;
3059
3060 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3061 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3062 {
3063 tempitemx=x;
3064 tempitemy=y;
3065 }
3066
3067 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3068 }
3069
3070 break;
3071
3072 case mfBOMB:
3073
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3074 {
3075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3076 16 }
3077 else
3078 {
3079 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3080 17 tempweapon = wLitBomb;
3081
3082 //if (tempitem<0) break;
3083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3084
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3085 {
3086 12 tempweaponx=x;
3087 12 tempweapony=y;
3088 12 }
3089
3090 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3091 }
3092
3093 33 break;
3094
3095 case mfSBOMB:
3096
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3097 {
3098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3099 48 }
3100 else
3101 {
3102 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3103 //if (tempitem<0) break;
3104 48 tempweapon = wLitSBomb;
3105
3106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3107
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3108 {
3109 36 tempweaponx=x;
3110 36 tempweapony=y;
3111 36 }
3112
3113 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3114 }
3115
3116 96 break;
3117
3118 case mfARMOS_SECRET:
3119
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3120 {
3121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3122 12 }
3123 24 break;
3124
3125 case mfBRANG:
3126
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3127 {
3128 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3129 }
3130 else
3131 {
3132 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3133
3134
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3135
3136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3137
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3138 {
3139 4 tempitemx=x;
3140 4 tempitemy=y;
3141 4 }
3142
3143 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3144 }
3145
3146 5 break;
3147
3148 case mfMBRANG:
3149 if(!hints)
3150 {
3151 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3152 }
3153 else
3154 {
3155 tempitem=getItemID(itemsbuf,itype_brang,2);
3156
3157 if(tempitem<0) break;
3158
3159 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3160 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3161 {
3162 tempitemx=x;
3163 tempitemy=y;
3164 }
3165
3166 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3167 }
3168
3169 break;
3170
3171 case mfFBRANG:
3172 if(!hints)
3173 {
3174 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3175 }
3176 else
3177 {
3178 tempitem=getItemID(itemsbuf,itype_brang,3);
3179
3180 if(tempitem<0) break;
3181
3182 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3183 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3184 {
3185 tempitemx=x;
3186 tempitemy=y;
3187 }
3188
3189 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3190 }
3191
3192 break;
3193
3194 case mfWANDMAGIC:
3195 if(!hints)
3196 {
3197 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3198 }
3199 else
3200 {
3201 tempitem=getItemID(itemsbuf,itype_wand,1);
3202
3203 if(tempitem<0) break;
3204
3205 tempweapon=itemsbuf[tempitem].wpn3;
3206
3207 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3208 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3209 {
3210 tempitemx=x;
3211 tempitemy=y;
3212 }
3213 else
3214 {
3215 tempweaponx=x;
3216 tempweapony=y;
3217 --lens_hint_weapon[wMagic][4];
3218
3219 if(lens_hint_weapon[wMagic][4]<-8)
3220 {
3221 lens_hint_weapon[wMagic][4]=8;
3222 }
3223 }
3224
3225 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3226 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3227 }
3228
3229 break;
3230
3231 case mfREFMAGIC:
3232
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3233 {
3234 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3235 }
3236 else
3237 {
3238 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3239
3240
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3241
3242 16 tempweapon=ewMagic;
3243
3244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3245
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3246 {
3247 13 tempitemx=x;
3248 13 tempitemy=y;
3249 13 }
3250 else
3251 {
3252 3 tempweaponx=x;
3253 3 tempweapony=y;
3254
3255
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3256 {
3257 1 --lens_hint_weapon[ewMagic][4];
3258 1 }
3259 else
3260 {
3261 2 ++lens_hint_weapon[ewMagic][4];
3262 }
3263
3264
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3265 {
3266 lens_hint_weapon[ewMagic][2]=up;
3267 }
3268
3269
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3270 {
3271 2 lens_hint_weapon[ewMagic][2]=down;
3272 2 }
3273 }
3274
3275 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3276 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3277 }
3278
3279 16 break;
3280
3281 case mfREFFIREBALL:
3282
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3283 {
3284 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3285 }
3286 else
3287 {
3288 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3289
3290
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3291
3292 16 tempweapon=ewFireball;
3293
3294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3295
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3296 {
3297 12 tempitemx=x;
3298 12 tempitemy=y;
3299 12 tempweaponx=x;
3300 12 tempweapony=y;
3301 12 ++lens_hint_weapon[ewFireball][3];
3302
3303
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3304 {
3305 1 lens_hint_weapon[ewFireball][3]=-8;
3306 1 lens_hint_weapon[ewFireball][4]=8;
3307 1 }
3308
3309
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3310 {
3311 8 ++lens_hint_weapon[ewFireball][4];
3312 8 }
3313 else
3314 {
3315 4 --lens_hint_weapon[ewFireball][4];
3316 }
3317 12 }
3318
3319 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3320 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3321 }
3322
3323 16 break;
3324
3325 case mfSWORD:
3326
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3327 {
3328 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3329 }
3330 else
3331 {
3332 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3333
3334
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3335
3336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3337
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3338 {
3339 5 tempitemx=x;
3340 5 tempitemy=y;
3341 5 }
3342
3343 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3344 }
3345
3346 7 break;
3347
3348 case mfWSWORD:
3349 if(!hints)
3350 {
3351 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3352 }
3353 else
3354 {
3355 tempitem=getItemID(itemsbuf,itype_sword,2);
3356
3357 if(tempitem<0) break;
3358
3359 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3360 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3361 {
3362 tempitemx=x;
3363 tempitemy=y;
3364 }
3365
3366 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3367 }
3368
3369 break;
3370
3371 case mfMSWORD:
3372 if(!hints)
3373 {
3374 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3375 }
3376 else
3377 {
3378 tempitem=getItemID(itemsbuf,itype_sword,3);
3379
3380 if(tempitem<0) break;
3381
3382 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3383 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3384 {
3385 tempitemx=x;
3386 tempitemy=y;
3387 }
3388
3389 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3390 }
3391
3392 break;
3393
3394 case mfXSWORD:
3395 if(!hints)
3396 {
3397 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3398 }
3399 else
3400 {
3401 tempitem=getItemID(itemsbuf,itype_sword,4);
3402
3403 if(tempitem<0) break;
3404
3405 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3406 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3407 {
3408 tempitemx=x;
3409 tempitemy=y;
3410 }
3411
3412 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3413 }
3414
3415 break;
3416
3417 case mfSWORDBEAM:
3418
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3419 {
3420 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3421 }
3422 else
3423 {
3424 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3425
3426
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3427
3428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3429
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3430 {
3431 11 tempitemx=x;
3432 11 tempitemy=y;
3433 11 }
3434
3435 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3436 }
3437
3438 16 break;
3439
3440 case mfWSWORDBEAM:
3441 if(!hints)
3442 {
3443 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3444 }
3445 else
3446 {
3447 tempitem=getItemID(itemsbuf,itype_sword,2);
3448
3449 if(tempitem<0) break;
3450
3451 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3452 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3453 {
3454 tempitemx=x;
3455 tempitemy=y;
3456 }
3457
3458 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3459 }
3460
3461 break;
3462
3463 case mfMSWORDBEAM:
3464 if(!hints)
3465 {
3466 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3467 }
3468 else
3469 {
3470 tempitem=getItemID(itemsbuf,itype_sword,3);
3471
3472 if(tempitem<0) break;
3473
3474 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3475 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3476 {
3477 tempitemx=x;
3478 tempitemy=y;
3479 }
3480
3481 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3482 }
3483
3484 break;
3485
3486 case mfXSWORDBEAM:
3487 if(!hints)
3488 {
3489 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3490 }
3491 else
3492 {
3493 tempitem=getItemID(itemsbuf,itype_sword,4);
3494
3495 if(tempitem<0) break;
3496
3497 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3498 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3499 {
3500 tempitemx=x;
3501 tempitemy=y;
3502 }
3503
3504 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3505 }
3506
3507 break;
3508
3509 case mfHOOKSHOT:
3510
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3511 {
3512 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3513 }
3514 else
3515 {
3516 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3517
3518
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3519
3520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3521
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3522 {
3523 12 tempitemx=x;
3524 12 tempitemy=y;
3525 12 }
3526
3527 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3528 }
3529
3530 17 break;
3531
3532 case mfWAND:
3533
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3534 {
3535 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3536 }
3537 else
3538 {
3539 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3540
3541
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3542
3543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3544
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3545 {
3546 28 tempitemx=x;
3547 28 tempitemy=y;
3548 28 }
3549
3550 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3551 }
3552
3553 35 break;
3554
3555 case mfHAMMER:
3556
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3557 {
3558 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3559 }
3560 else
3561 {
3562 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3563
3564
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3565
3566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3567
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3568 {
3569 13 tempitemx=x;
3570 13 tempitemy=y;
3571 13 }
3572
3573 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3574 }
3575
3576 17 break;
3577
3578 case mfARMOS_ITEM:
3579 case mfDIVE_ITEM:
3580
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3581 {
3582 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3583 2064 }
3584 2064 break;
3585
3586 case 16:
3587 case 17:
3588 case 18:
3589 case 19:
3590 case 20:
3591 case 21:
3592 case 22:
3593 case 23:
3594 case 24:
3595 case 25:
3596 case 26:
3597 case 27:
3598 case 28:
3599 case 29:
3600 case 30:
3601 case 31:
3602
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3604 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3605
3606 3618 break;
3607 case mfSECRETSNEXT:
3608 if(!hints)
3609 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3610 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3611
3612 break;
3613
3614 case mfSTRIKE:
3615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3616 {
3617 906 goto special;
3618 }
3619 else
3620 {
3621 break;
3622 }
3623
3624 28640 default: goto special;
3625
3626 special:
3627
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3628 {
3629
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3630 {
3631 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3632 4913 }
3633 6549 }
3634
3635 29546 break;
3636 }
3637 5748864 }
3638 2874432 }
3639
3640
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3641 {
3642
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3643 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3644
3645
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3646 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3647
3648
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3649 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3650
3651
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3652 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3653
3654
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3655 {
3656 43 showbombeddoor(dest, 0);
3657 43 }
3658
3659
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3660 {
3661 39 showbombeddoor(dest, 1);
3662 39 }
3663
3664
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3665 {
3666 showbombeddoor(dest, 2);
3667 }
3668
3669
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3670 {
3671 37 showbombeddoor(dest, 3);
3672 37 }
3673 8166 }
3674
3675
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3676 {
3677
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3678 {
3679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3680 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3681 1123 }
3682 else
3683 {
3684
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3685 {
3686 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3687 48 int32_t tempitemx=-16;
3688 48 int32_t tempitemy=-16;
3689
3690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3691
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3692 {
3693 24 tempitemx=tmpscr->stairx;
3694 24 tempitemy=tmpscr->stairy+playing_field_offset;
3695 24 }
3696
3697 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3698 48 }
3699 }
3700 2034 }
3701 }
3702 16332 }
3703
3704 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3705
3706 7997 void draw_lens_over()
3707 {
3708 // Oh, what the heck.
3709 static BITMAP *lens_scr = NULL;
3710 static int32_t last_width = -1;
3711 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3712
3713 // Only redraw the circle if the size has changed
3714
2/2
✓ Branch 0 taken 7987 times.
✓ Branch 1 taken 10 times.
7997 if(width != last_width)
3715 {
3716
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(lens_scr == NULL)
3717 {
3718 10 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3719 10 }
3720
3721 10 clear_to_color(lens_scr, BLACK);
3722 10 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3723 10 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3724 10 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3725 10 last_width=width;
3726 10 }
3727
3728 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3729 7997 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3730 7997 }
3731
3732 //----------------------------------------------------------------
3733
3734 31111 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3735 {
3736 //recreating a big bitmap every frame is highly sluggish.
3737
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 31108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
31111 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3738 31111 clear_to_color(wavebuf, BLACK);
3739 31111 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3740
3741 int32_t ofs;
3742 // int32_t amplitude=8;
3743 // int32_t wavelength=4;
3744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31111 times.
31111 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3745
3/6
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3746 31111 int32_t amp2=168;
3747
2/4
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3748 31111 int32_t i=frame%amp2;
3749
3750
2/2
✓ Branch 0 taken 5226648 times.
✓ Branch 1 taken 31111 times.
5257759 for(int32_t j=0; j<168; j++)
3751 {
3752
3/4
✓ Branch 0 taken 2613324 times.
✓ Branch 1 taken 2613324 times.
✓ Branch 2 taken 2613324 times.
✗ Branch 3 not taken.
5226648 if(j&1 && interpol)
3753 {
3754 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3755 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3756 }
3757 else
3758 {
3759 5226648 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3760 }
3761
3762
1/2
✓ Branch 0 taken 5226648 times.
✗ Branch 1 not taken.
5226648 if(ofs)
3763 {
3764
2/2
✓ Branch 0 taken 1338021888 times.
✓ Branch 1 taken 5226648 times.
1343248536 for(int32_t k=0; k<256; k++)
3765 {
3766 1338021888 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3767 1338021888 }
3768 5226648 }
3769 5226648 }
3770 31111 }
3771
3772 4848 void draw_fuzzy(int32_t fuzz)
3773 // draws from right half of scrollbuf to framebuf
3774 {
3775 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3776 byte *start, *si, *di;
3777
3778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4848 times.
4848 if(fuzz<1)
3779 fuzz = 1;
3780
3781 4848 xstep = 128%fuzz;
3782
3783
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 3838 times.
4848 if(xstep > 0)
3784 3838 xstep = fuzz-xstep;
3785
3786 4848 ystep = 112%fuzz;
3787
3788
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 3434 times.
4848 if(ystep > 0)
3789 3434 ystep = fuzz-ystep;
3790
3791 4848 firsty = 1;
3792
3793
2/2
✓ Branch 0 taken 4848 times.
✓ Branch 1 taken 174932 times.
179780 for(y=0; y<224;)
3794 {
3795 174932 start = &(scrollbuf->line[y][256]);
3796
3797
4/4
✓ Branch 0 taken 172508 times.
✓ Branch 1 taken 1088376 times.
✓ Branch 2 taken 1085952 times.
✓ Branch 3 taken 174932 times.
1260884 for(dy=0; dy<ystep && dy+y<224; dy++)
3798 {
3799 1085952 si = start;
3800 1085952 di = &(framebuf->line[y+dy][0]);
3801 1085952 i = xstep;
3802 1085952 firstx = 1;
3803
3804
2/2
✓ Branch 0 taken 278003712 times.
✓ Branch 1 taken 1085952 times.
279089664 for(dx=0; dx<256; dx++)
3805 {
3806 278003712 *(di++) = *si;
3807
3808
2/2
✓ Branch 0 taken 234248896 times.
✓ Branch 1 taken 43754816 times.
278003712 if(++i >= fuzz)
3809 {
3810
2/2
✓ Branch 0 taken 42668864 times.
✓ Branch 1 taken 1085952 times.
43754816 if(!firstx)
3811 42668864 si += fuzz;
3812 else
3813 {
3814 1085952 si += fuzz-xstep;
3815 1085952 firstx = 0;
3816 }
3817
3818 43754816 i = 0;
3819 43754816 }
3820 278003712 }
3821 1085952 }
3822
3823
2/2
✓ Branch 0 taken 170084 times.
✓ Branch 1 taken 4848 times.
174932 if(!firsty)
3824 170084 y += fuzz;
3825 else
3826 {
3827 4848 y += ystep;
3828 4848 ystep = fuzz;
3829 4848 firsty = 0;
3830 }
3831 }
3832 4848 }
3833
3834 9287337 void updatescr(bool allowwavy)
3835 {
3836
4/6
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 9287220 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
9287337 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3837
4/6
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 9287220 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 117 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 117 times.
9287337 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3838
3839
2/2
✓ Branch 0 taken 9260572 times.
✓ Branch 1 taken 26765 times.
9287337 if(toogam)
3840 {
3841 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3842 26765 }
3843
3844
1/2
✓ Branch 0 taken 9287337 times.
✗ Branch 1 not taken.
9287337 if(Showpal)
3845 dump_pal(framebuf);
3846
3847
2/2
✓ Branch 0 taken 8986105 times.
✓ Branch 1 taken 301232 times.
9287337 if(!Playing)
3848 301232 black_opening_count=0;
3849
3850
2/2
✓ Branch 0 taken 9213945 times.
✓ Branch 1 taken 73392 times.
9287337 if(black_opening_count<0) //shape is opening up
3851 {
3852 73392 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3853
3854
2/4
✓ Branch 0 taken 73392 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73392 times.
73392 if(Advance||(!Paused))
3855 {
3856 73392 ++black_opening_count;
3857 73392 }
3858 73392 }
3859
2/2
✓ Branch 0 taken 9187809 times.
✓ Branch 1 taken 26136 times.
9213945 else if(black_opening_count>0) //shape is closing
3860 {
3861 26136 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3862
3863
2/4
✓ Branch 0 taken 26136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26136 times.
26136 if(Advance||(!Paused))
3864 {
3865 26136 --black_opening_count;
3866 26136 }
3867 26136 }
3868
3869
3/4
✓ Branch 0 taken 9189317 times.
✓ Branch 1 taken 98020 times.
✓ Branch 2 taken 9189317 times.
✗ Branch 3 not taken.
9287337 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3870 {
3871 black_opening_shape = bosCIRCLE;
3872 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3873 refreshTints();
3874 refreshpal=true;
3875 }
3876
3877
2/2
✓ Branch 0 taken 9033135 times.
✓ Branch 1 taken 254202 times.
9287337 if(refreshpal)
3878 {
3879 254202 refreshpal=false;
3880 254202 RAMpal[253] = _RGB(0,0,0);
3881 254202 RAMpal[254] = _RGB(63,63,63);
3882 254202 hw_palette = &RAMpal;
3883 254202 update_hw_pal = true;
3884
3885 254202 create_rgb_table(&rgb_table, RAMpal, NULL);
3886 254202 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3887 254202 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3888
3889
2/2
✓ Branch 0 taken 65075712 times.
✓ Branch 1 taken 254202 times.
65329914 for(int32_t q=0; q<PAL_SIZE; q++)
3890 {
3891 65075712 trans_table2.data[0][q] = q;
3892 65075712 trans_table2.data[q][q] = q;
3893 65075712 }
3894 254202 }
3895
3896 9287337 bool clearwavy = (wavy <= 0);
3897
3898
2/2
✓ Branch 0 taken 7655 times.
✓ Branch 1 taken 9279682 times.
9287337 if(wavy <= 0)
3899 {
3900 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3901 9279682 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3902 9279682 }
3903
3904 9287337 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3905
3906
6/6
✓ Branch 0 taken 31361 times.
✓ Branch 1 taken 9255976 times.
✓ Branch 2 taken 31239 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31111 times.
9287337 if(wavy && Playing && allowwavy)
3907 {
3908 31111 draw_wavy(framebuf, wavybuf, wavy,false);
3909 31111 }
3910
3911
2/2
✓ Branch 0 taken 9279682 times.
✓ Branch 1 taken 7655 times.
9287337 if(clearwavy)
3912 9279682 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3913
2/4
✓ Branch 0 taken 7655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7655 times.
7655 else if(Playing && !Paused)
3914 7655 wavy--; // Wavy was set by a script. Decrement it.
3915
3916
5/6
✓ Branch 0 taken 8986105 times.
✓ Branch 1 taken 301232 times.
✓ Branch 2 taken 259574 times.
✓ Branch 3 taken 8726531 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259574 times.
9287337 if(Playing && msgpos && !screenscrolling)
3917 {
3918
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_bg_display_buf->clip))
3919 259574 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3920
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_portrait_display_buf->clip))
3921 259574 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3922
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_txt_display_buf->clip))
3923 259574 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3924 259574 }
3925
3926 /*
3927 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3928 {
3929 BITMAP* subBmp = 0;
3930 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3931 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3932 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3933 destroy_bitmap(subBmp);
3934 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3935 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3936 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3937 }
3938 */
3939
3940
2/2
✓ Branch 0 taken 9246280 times.
✓ Branch 1 taken 41057 times.
9287337 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3941
3942
2/2
✓ Branch 0 taken 9250905 times.
✓ Branch 1 taken 36432 times.
9287337 if(nosubscr)
3943 {
3944 36432 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3945 36432 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3946 36432 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3947 36432 }
3948
3949 //TODO: Optimize blit 'overcalls' -Gleeok
3950
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9250905 times.
9287337 BITMAP *source = nosubscr ? panorama : wavybuf;
3951 9287337 blit(source,framebuf,0,0,0,0,256,224);
3952
3953 9287337 update_hw_screen();
3954 9287337 }
3955
3956 //----------------------------------------------------------------
3957
3958 static PALETTE syspal;
3959 int32_t onGUISnapshot()
3960 {
3961 char buf[200];
3962 int32_t num=0;
3963 do
3964 {
3965 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3966 }
3967 while(num<99999 && exists(buf));
3968
3969 if (!al_save_bitmap(buf, al_get_backbuffer(all_get_display())))
3970 InfoDialog("Error", "Failed to save snapshot").show();
3971
3972 return D_O_K;
3973 }
3974
3975 int32_t onNonGUISnapshot()
3976 {
3977 PALETTE temppal;
3978 get_palette(temppal);
3979 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3980
3981 char buf[200];
3982 int32_t num=0;
3983
3984 do
3985 {
3986 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3987 }
3988 while(num<99999 && exists(buf));
3989
3990 if (tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3991 {
3992 BITMAP *b = create_bitmap_ex(8,256,168);
3993 clear_to_color(b,0);
3994 blit(framebuf,b,0,passive_subscreen_height/2,0,0,256,168);
3995 alleg4_save_bitmap(b, SnapshotScale, buf);
3996 destroy_bitmap(b);
3997 }
3998 else
3999 {
4000 alleg4_save_bitmap(framebuf, SnapshotScale, buf, realpal?temppal:RAMpal);
4001 }
4002
4003 return D_O_K;
4004 }
4005
4006 int32_t onSnapshot()
4007 {
4008 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
4009 {
4010 onGUISnapshot();
4011 }
4012 else
4013 {
4014 onNonGUISnapshot();
4015 }
4016
4017 return D_O_K;
4018 }
4019
4020 int32_t onSaveMapPic()
4021 {
4022 int32_t mapres2 = 0;
4023 char buf[200];
4024 int32_t num=0;
4025 mapscr tmpscr_b[2];
4026 mapscr tmpscr_c[6];
4027 BITMAP* _screen_draw_buffer = NULL;
4028 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4029 set_clip_state(_screen_draw_buffer,1);
4030
4031 for(int32_t i=0; i<6; ++i)
4032 {
4033 tmpscr_c[i] = tmpscr2[i];
4034 tmpscr2[i].zero_memory();
4035
4036 if(i>=2)
4037 {
4038 continue;
4039 }
4040
4041 tmpscr_b[i] = tmpscr[i];
4042 tmpscr[i].zero_memory();
4043 }
4044
4045 do
4046 {
4047 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4048 }
4049 while(num<99999 && exists(buf));
4050
4051 BITMAP* mappic = NULL;
4052
4053
4054 bool done=false, redraw=true;
4055
4056 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4057
4058 if(!mappic)
4059 {
4060 enter_sys_pal();
4061 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4062 exit_sys_pal();
4063 return D_O_K;;
4064 }
4065
4066 // draw the map
4067 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4068
4069 for(int32_t y=0; y<8; y++)
4070 {
4071 for(int32_t x=0; x<16; x++)
4072 {
4073 if(!displayOnMap(x, y))
4074 {
4075 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4076 }
4077 else
4078 {
4079 int32_t s = (y<<4) + x;
4080 loadscr2(1,s,-1);
4081
4082 for(int32_t i=0; i<6; i++)
4083 {
4084 if(tmpscr[1].layermap[i]<=0)
4085 continue;
4086
4087 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4088 }
4089
4090 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4091
4092 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4093
4094 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4095 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4096
4097 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4098
4099 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4100 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4101 {
4102 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4103 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4104 {
4105 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4106 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4107 }
4108 }
4109 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4110
4111 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4112
4113 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4114 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4115 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4116 {
4117 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4118 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4119 }
4120 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4121 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4122
4123 }
4124
4125 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4126 }
4127 }
4128
4129 for(int32_t i=0; i<6; ++i)
4130 {
4131 tmpscr2[i]=tmpscr_c[i];
4132
4133 if(i>=2)
4134 {
4135 continue;
4136 }
4137
4138 tmpscr[i]=tmpscr_b[i];
4139 }
4140
4141 save_bitmap(buf,mappic,RAMpal);
4142 destroy_bitmap(mappic);
4143 destroy_bitmap(_screen_draw_buffer);
4144 return D_O_K;
4145 }
4146
4147 14 void f_Quit(int32_t type)
4148 {
4149
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4150 return;
4151
4152 14 bool from_menu = is_sys_pal;
4153
4154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4155 {
4156 14 music_pause();
4157 14 pause_all_sfx();
4158 14 sys_mouse();
4159 14 }
4160 14 enter_sys_pal();
4161 14 clear_keybuf();
4162
4163
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (replay_version_check(0, 10))
4164 13 replay_poll();
4165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4166 14 replay_peek_quit();
4167
4168
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4169 switch(type)
4170 {
4171 case qQUIT:
4172 onQuit();
4173 break;
4174
4175 case qRESET:
4176 onReset();
4177 break;
4178
4179 case qEXIT:
4180 onExit();
4181 break;
4182 }
4183
4184
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4185 {
4186 14 kill_sfx();
4187 14 music_stop();
4188 14 exit_sys_pal();
4189 14 update_hw_screen();
4190 14 }
4191 else
4192 {
4193 exit_sys_pal();
4194 if(!from_menu)
4195 {
4196 music_resume();
4197 resume_all_sfx();
4198 }
4199 }
4200
4201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4202 14 game_mouse();
4203 14 eat_buttons();
4204
4205 14 zc_readrawkey(KEY_ESC);
4206
4207 14 zc_readrawkey(KEY_ENTER);
4208 14 }
4209
4210 //----------------------------------------------------------------
4211
4212 int32_t onNoWalls()
4213 {
4214 cheats_enqueue(Cheat::Walls);
4215 return D_O_K;
4216 }
4217
4218 int32_t onIgnoreSideview()
4219 {
4220 cheats_enqueue(Cheat::IgnoreSideView);
4221 return D_O_K;
4222 }
4223
4224 9287211 int32_t input_idle(bool checkmouse)
4225 {
4226 static int32_t mx, my, mz, mb;
4227
4228
4/6
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461754 times.
✓ Branch 3 taken 6825457 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2461754 times.
11748965 if(keypressed() || zc_key_pressed() ||
4229
4/8
✓ Branch 0 taken 2461754 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461754 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2461754 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2461754 times.
✗ Branch 7 not taken.
2461754 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4230 {
4231 6825457 idle_count = 0;
4232
4233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6825457 times.
6825457 if(active_count < MAX_ACTIVE)
4234 {
4235 6825457 ++active_count;
4236 6825457 }
4237 6825457 }
4238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2461754 times.
2461754 else if(idle_count < MAX_IDLE)
4239 {
4240 2461754 ++idle_count;
4241 2461754 active_count = 0;
4242 2461754 }
4243
4244 9287211 mx = mouse_x;
4245 9287211 my = mouse_y;
4246 9287211 mz = mouse_z;
4247 9287211 mb = mouse_b;
4248
4249 9287211 return idle_count;
4250 }
4251
4252 int32_t onGoFast()
4253 {
4254 cheats_enqueue(Cheat::Fast);
4255 return D_O_K;
4256 }
4257
4258 int32_t onKillCheat()
4259 {
4260 cheats_enqueue(Cheat::Kill);
4261 return D_O_K;
4262 }
4263
4264 int32_t onSecretsCheat()
4265 {
4266 cheats_enqueue(Cheat::TrigSecrets);
4267 return D_O_K;
4268 }
4269 int32_t onSecretsCheatPerm()
4270 {
4271 cheats_enqueue(Cheat::TrigSecretsPerm);
4272 return D_O_K;
4273 }
4274
4275 int32_t onShowLayer0()
4276 {
4277 show_layer_0 = !show_layer_0;
4278 return D_O_K;
4279 }
4280 int32_t onShowLayer1()
4281 {
4282 show_layer_1 = !show_layer_1;
4283 return D_O_K;
4284 }
4285 int32_t onShowLayer2()
4286 {
4287 show_layer_2 = !show_layer_2;
4288 return D_O_K;
4289 }
4290 int32_t onShowLayer3()
4291 {
4292 show_layer_3 = !show_layer_3;
4293 return D_O_K;
4294 }
4295 int32_t onShowLayer4()
4296 {
4297 show_layer_4 = !show_layer_4;
4298 return D_O_K;
4299 }
4300 int32_t onShowLayer5()
4301 {
4302 show_layer_5 = !show_layer_5;
4303 return D_O_K;
4304 }
4305 int32_t onShowLayer6()
4306 {
4307 show_layer_6 = !show_layer_6;
4308 return D_O_K;
4309 }
4310 int32_t onShowLayerO()
4311 {
4312 show_layer_over=!show_layer_over;
4313 return D_O_K;
4314 }
4315 int32_t onShowLayerP()
4316 {
4317 show_layer_push=!show_layer_push;
4318 return D_O_K;
4319 }
4320 int32_t onShowLayerS()
4321 {
4322 show_sprites=!show_sprites;
4323 return D_O_K;
4324 }
4325 int32_t onShowLayerF()
4326 {
4327 show_ffcs=!show_ffcs;
4328 return D_O_K;
4329 }
4330 int32_t onShowLayerW()
4331 {
4332 show_walkflags=!show_walkflags;
4333 if(show_walkflags)
4334 show_effectflags = false;
4335 return D_O_K;
4336 }
4337 int32_t onShowLayerE()
4338 {
4339 show_effectflags=!show_effectflags;
4340 if(show_effectflags)
4341 show_walkflags = false;
4342 return D_O_K;
4343 }
4344 int32_t onShowFFScripts()
4345 {
4346 show_ff_scripts=!show_ff_scripts;
4347 return D_O_K;
4348 }
4349 int32_t onShowHitboxes()
4350 {
4351 show_hitboxes=!show_hitboxes;
4352 return D_O_K;
4353 }
4354 int32_t onShowInfoOpacity()
4355 {
4356 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4357 zc_set_config("zc","debug_info_opacity",info_opacity);
4358 return D_O_K;
4359 }
4360
4361 int32_t onLightSwitch()
4362 {
4363 cheats_enqueue(Cheat::Light);
4364 return D_O_K;
4365 }
4366
4367 int32_t onGoTo();
4368 int32_t onGoToComplete();
4369
4370 9287211 bool handle_close_btn_quit()
4371 {
4372
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(close_button_quit)
4373 {
4374 close_button_quit=false;
4375 f_Quit(qEXIT);
4376 }
4377 9287211 return (exiting_program = Quit==qEXIT);
4378 }
4379
4380 9287211 void syskeys()
4381 {
4382 9287211 update_system_keys();
4383
4384 int32_t oldtitle_version;
4385
4386 9287211 poll_joystick();
4387
4388 9287211 handle_close_btn_quit();
4389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
9287211 if(Quit == qEXIT) return;
4390
4391
2/10
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9287211 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9287211 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4392 {
4393 System();
4394 }
4395
4396 9287211 mouse_down=gui_mouse_b();
4397
4398
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(zc_read_system_key(KEY_F1))
4399 {
4400 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4401 {
4402 halt=!halt;
4403 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4404 }
4405 else
4406 {
4407 Throttlefps=!Throttlefps;
4408 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4409 }
4410 }
4411
4412 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4413 /*
4414 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4415 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4416 */
4417
4418
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(zc_read_system_key(KEY_F2))
4419 {
4420 ShowFPS=!ShowFPS;
4421 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4422 }
4423
4424
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9287211 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4425
4426
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9287211 if(zc_read_system_key(KEY_F4) && Playing)
4427 {
4428 Paused=true;
4429 Advance=true;
4430 }
4431
4432
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(zc_read_system_key(KEY_F6)) onTryQuit();
4433
4434 #ifndef ALLEGRO_MACOSX
4435
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4436
4437
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4438 #else
4439 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4440
4441 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4442 #endif
4443
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9287211 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4444
4445
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if (zc_read_system_key(KEY_F12))
4446 {
4447 onSnapshot();
4448 }
4449
4450
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9287211 if(debug_enabled && zc_read_system_key(KEY_TAB))
4451 set_debug(!get_debug());
4452
4453
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(CheatModifierKeys())
4454 {
4455 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4456 {
4457 if(!bindable_cheat(c))
4458 continue;
4459 if(get_debug() || cheat >= cheat_lvl(c))
4460 {
4461 if(checkcheat(c))
4462 cheats_hit_bind(c);
4463 }
4464 }
4465 }
4466
4467
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(volkeys)
4468 {
4469 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4470
4471 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4472
4473 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4474
4475 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4476 }
4477
4478
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9287211 if(!get_debug() || !SystemKeys || replay_is_replaying())
4479 9287211 goto bottom;
4480
4481 if(zc_readkey(KEY_D))
4482 {
4483 details = !details;
4484 rectfill(screen,0,0,319,7,BLACK);
4485 rectfill(screen,0,8,31,239,BLACK);
4486 rectfill(screen,288,8,319,239,BLACK);
4487 rectfill(screen,32,232,287,239,BLACK);
4488 }
4489
4490 if(zc_readkey(KEY_P)) Paused=!Paused;
4491
4492 //if(zc_readkey(KEY_P)) centerHero();
4493 if(zc_readkey(KEY_A))
4494 {
4495 Paused=true;
4496 Advance=true;
4497 }
4498
4499 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4500 #ifndef ALLEGRO_MACOSX
4501 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4502
4503 if(zc_readkey(KEY_F7))
4504 {
4505 Matrix(ss_speed, ss_density, 0);
4506 game_pal();
4507 }
4508 #else
4509 // The reason these are different on Mac in the first place is that
4510 // the OS doesn't let us use F9 and F10...
4511 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4512
4513 if(zc_readkey(KEY_F9))
4514 {
4515 Matrix(ss_speed, ss_density, 0);
4516 game_pal();
4517 }
4518 #endif
4519 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4520 {
4521 //change containers
4522 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4523 {
4524 //magic containers
4525 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4526 {
4527 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4528 }
4529 else
4530 {
4531 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4532 }
4533 }
4534 else
4535 {
4536 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4537 {
4538 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4539 }
4540 else
4541 {
4542 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4543 }
4544 }
4545 }
4546
4547 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4548 {
4549 //change containers
4550 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4551 {
4552 //magic containers
4553 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4554 {
4555 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4556 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4557 //heart containers
4558 }
4559 else
4560 {
4561 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4562 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4563 }
4564 }
4565 else
4566 {
4567 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4568 {
4569 game->set_magic(zc_max(game->get_magic()-1,0));
4570 }
4571 else
4572 {
4573 game->set_life(zc_max(game->get_life()-1,0));
4574 }
4575 }
4576 }
4577
4578 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4579
4580 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4581
4582 verifyBothWeapons();
4583
4584 bottom:
4585
4586
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(input_idle(true) > after_time())
4587 {
4588 Matrix(ss_speed, ss_density, 0);
4589 game_pal();
4590 }
4591 9287211 }
4592
4593 708292 void checkQuitKeys()
4594 {
4595 #ifndef ALLEGRO_MACOSX
4596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708292 times.
708292 if(key[KEY_F9]) f_Quit(qRESET);
4597
4598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708292 times.
708292 if(key[KEY_F10]) f_Quit(qEXIT);
4599 #else
4600 if(key[KEY_F7]) f_Quit(qRESET);
4601
4602 if(key[KEY_F8]) f_Quit(qEXIT);
4603 #endif
4604 708292 }
4605
4606 9287211 bool CheatModifierKeys()
4607 {
4608 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4609 // to trigger cheats.
4610
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if (replay_is_replaying())
4611 9287211 return false;
4612
4613 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4614 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4615 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4616 {
4617 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4618 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4619 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4620 {
4621 return true;
4622 }
4623 }
4624 return false;
4625 9287211 }
4626
4627 //99:05:54, for some reason?
4628 #define OLDMAXTIME 21405240
4629 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4630 #define MAXTIME 1944000000
4631
4632 9287337 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4633 {
4634
1/2
✓ Branch 0 taken 9287337 times.
✗ Branch 1 not taken.
9287337 if(zcmusic!=NULL)
4635 {
4636 zcmusic_poll();
4637 }
4638 9287337 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4639
4640 9287337 updatescr(allowwavy);
4641
4642 9287337 Advance=false;
4643
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9287337 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9287337 times.
9287337 while(Paused && !Advance && !Quit)
4644 {
4645 // have to call this, otherwise we'll get an infinite loop
4646 syskeys();
4647 if(allowF6Script)
4648 {
4649 FFCore.runF6Engine();
4650 }
4651 zc_throttle_fps();
4652
4653 #ifdef _WIN32
4654
4655 if(use_dwm_flush)
4656 {
4657 do_DwmFlush();
4658 }
4659
4660 #endif
4661
4662 // to keep music playing
4663 if(zcmusic!=NULL)
4664 {
4665 zcmusic_poll();
4666 }
4667
4668 update_hw_screen();
4669 }
4670
4671
2/2
✓ Branch 0 taken 9287225 times.
✓ Branch 1 taken 112 times.
9287337 if(Quit)
4672 112 return;
4673
4674
3/4
✓ Branch 0 taken 8986096 times.
✓ Branch 1 taken 301129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8986096 times.
9287225 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4675 8986096 game->change_time(1);
4676
4677 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4678
4679 9287225 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4680
2/2
✓ Branch 0 taken 20428 times.
✓ Branch 1 taken 9266797 times.
9287225 if (replay_version_check(0, 16))
4681 9266797 should_reset_down_state = replay_version_check(11, 16);
4682
2/2
✓ Branch 0 taken 6949680 times.
✓ Branch 1 taken 2337545 times.
9287225 if (should_reset_down_state)
4683 {
4684
2/2
✓ Branch 0 taken 42075810 times.
✓ Branch 1 taken 2337545 times.
44413355 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4685 42075810 down_control_states[i] = raw_control_state[i];
4686 2337545 }
4687
4688
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9287211 times.
9287225 if (replay_is_active())
4689 {
4690
2/2
✓ Branch 0 taken 1270449 times.
✓ Branch 1 taken 8016762 times.
9287211 if (replay_version_check(3))
4691 8016762 replay_poll();
4692
4693
4/4
✓ Branch 0 taken 6946098 times.
✓ Branch 1 taken 2341113 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6845563 times.
9287211 if (replay_version_check(11) || replay_version_check(6, 8))
4694 2441648 replay_peek_input();
4695 9287211 }
4696
4697 9287225 load_control_called_this_frame = false;
4698
4699 9287225 poll_keyboard();
4700 9287225 update_keys();
4701
4702 9287225 ++frame;
4703
4704
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9287211 times.
9287225 if (replay_is_replaying())
4705 9287211 replay_do_cheats();
4706 9287225 syskeys();
4707
4708 // The mouse variables can change from the mouse thread at anytime during a frame,
4709 // so save the result at the start so that replaying is consistent.
4710 9287225 script_mouse_x = gui_mouse_x();
4711 9287225 script_mouse_y = gui_mouse_y();
4712 9287225 script_mouse_z = mouse_z;
4713 9287225 script_mouse_b = mouse_b;
4714
4715 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4716 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4717 // approach here means it doesn't matter which call adds the cheat.
4718 9287225 cheats_execute_queued();
4719
4720
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9287211 times.
9287225 if (replay_is_replaying())
4721 9287211 replay_peek_quit();
4722
2/2
✓ Branch 0 taken 9287211 times.
✓ Branch 1 taken 14 times.
9287225 if (GameFlags & GAMEFLAG_TRYQUIT)
4723 14 replay_step_quit(0);
4724
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 9284291 times.
9287225 if(allowF6Script)
4725 9284291 FFCore.runF6Engine();
4726
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 9286924 times.
9287225 if (Quit)
4727 301 replay_step_quit(Quit);
4728 // Someday... maybe install a Turbo button here?
4729 9287225 zc_throttle_fps();
4730
4731 #ifdef _WIN32
4732
4733 if(use_dwm_flush)
4734 {
4735 do_DwmFlush();
4736 }
4737
4738 #endif
4739
4740 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4741
2/2
✓ Branch 0 taken 68758 times.
✓ Branch 1 taken 9218467 times.
9287225 if(sfxcleanup)
4742 9218467 sfx_cleanup();
4743
4744 9287225 jit_poll();
4745
4746 #ifdef __EMSCRIPTEN__
4747 // Yield the main thread back to the browser occasionally.
4748 if (is_headless())
4749 {
4750 static int rate = 10000;
4751 static int force_yield = rate;
4752 if (force_yield++ >= rate)
4753 {
4754 force_yield = 0;
4755 emscripten_sleep(0);
4756 }
4757 }
4758 #endif
4759
4760
4/6
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 9287108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
9287225 static bool test_mode_auto_restart = zc_get_config("zeldadx", "test_mode_auto_restart", false);
4761
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9287225 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9287225 if (zqtesting_mode && test_mode_auto_restart)
4762 {
4763 static auto last_write_time = fs::last_write_time(qstpath);
4764 static auto last_check = std::chrono::system_clock::now();
4765
4766 if (std::chrono::system_clock::now() - last_check > 200ms)
4767 {
4768 last_check = std::chrono::system_clock::now();
4769 auto write_time = fs::last_write_time(qstpath);
4770 if (last_write_time != write_time)
4771 {
4772 last_write_time = write_time;
4773 disableClickToFreeze = false;
4774 Quit = qRESET;
4775 replay_quit();
4776 }
4777 }
4778 }
4779 9287337 }
4780
4781 101 void zapout()
4782 {
4783 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4784 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4785
4786 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4787 101 script_drawing_commands.Clear();
4788
4789 // zap out
4790
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=1; i<=24; i++)
4791 {
4792 2424 draw_fuzzy(i);
4793 2424 advanceframe(true);
4794
4795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4796 {
4797 break;
4798 }
4799 2424 }
4800 101 }
4801
4802 101 void zapin()
4803 {
4804 101 FFCore.warpScriptCheck();
4805 101 draw_screen(tmpscr);
4806 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4807 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4808 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4809
4810 // zap out
4811 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4812
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=24; i>=1; i--)
4813 {
4814 2424 draw_fuzzy(i);
4815 2424 advanceframe(true);
4816
4817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4818 {
4819 break;
4820 }
4821 2424 }
4822 101 }
4823
4824
4825 65 void wavyout(bool showhero)
4826 {
4827 65 draw_screen(tmpscr, showhero);
4828 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4829
4830 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4831 65 clear_to_color(wavebuf,0);
4832 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4833
4834 static PALETTE wavepal;
4835
4836 int32_t ofs;
4837 65 int32_t amplitude=8;
4838
4839 65 int32_t wavelength=4;
4840 65 double palpos=0, palstep=4, palstop=126;
4841
4842 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4843
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4844 {
4845
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4846 {
4847 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4848 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4849 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4850 698880 }
4851
4852 2730 palpos+=palstep;
4853
4854
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4855 {
4856 2730 hw_palette = &wavepal;
4857 2730 update_hw_pal = true;
4858 2730 }
4859 else
4860 {
4861 hw_palette = &RAMpal;
4862 update_hw_pal = true;
4863 }
4864
4865
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4866 {
4867
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4868 {
4869 117411840 ofs=0;
4870
4871
4/4
✓ Branch 0 taken 57308160 times.
✓ Branch 1 taken 60103680 times.
✓ Branch 2 taken 28654080 times.
✓ Branch 3 taken 28654080 times.
117411840 if((j<i)&&(j&1))
4872 {
4873 28654080 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4874 28654080 }
4875
4876 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4877 117411840 }
4878 458640 }
4879
4880 2730 advanceframe(true);
4881
4882 // animate_combos();
4883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4884 break;
4885 2730 }
4886
4887 65 destroy_bitmap(wavebuf);
4888 65 }
4889
4890 65 void wavyin()
4891 {
4892 65 draw_screen(tmpscr);
4893 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4894
4895 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4896 65 clear_to_color(wavebuf,0);
4897 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4898
4899 static PALETTE wavepal;
4900
4901 //Breaks dark rooms.
4902 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4903 /*
4904 loadfullpal();
4905 loadlvlpal(DMaps[currdmap].color);
4906 ringcolor(false);
4907 */
4908 65 refreshpal=false;
4909 int32_t ofs;
4910 65 int32_t amplitude=8;
4911 65 int32_t wavelength=4;
4912 65 double palpos=168, palstep=4, palstop=126;
4913
4914 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4915
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4916 {
4917
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4918 {
4919 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4920 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4921 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4922 698880 }
4923
4924 2730 palpos-=palstep;
4925
4926
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4927 {
4928 2730 hw_palette = &wavepal;
4929 2730 update_hw_pal = true;
4930 2730 }
4931 else
4932 {
4933 hw_palette = &RAMpal;
4934 update_hw_pal = true;
4935 }
4936
4937
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4938 {
4939
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4940 {
4941 117411840 ofs=0;
4942
4943
4/4
✓ Branch 0 taken 59404800 times.
✓ Branch 1 taken 58007040 times.
✓ Branch 2 taken 30051840 times.
✓ Branch 3 taken 29352960 times.
117411840 if((j<(167-i))&&(j&1))
4944 {
4945 29352960 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4946 29352960 }
4947
4948 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4949 117411840 }
4950 458640 }
4951
4952 2730 advanceframe(true);
4953 // animate_combos();
4954
4955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4956 break;
4957 2730 }
4958
4959 65 destroy_bitmap(wavebuf);
4960 65 }
4961
4962 2168 void blackscr(int32_t fcnt,bool showsubscr)
4963 {
4964 2168 reset_pal_cycling();
4965 2168 script_drawing_commands.Clear();
4966
4967 2168 FFCore.warpScriptCheck();
4968 2168 bool showtime = game->should_show_time();
4969
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 64970 times.
67138 while(fcnt>0)
4970 {
4971 64970 clear_bitmap(framebuf);
4972
4973
2/2
✓ Branch 0 taken 25080 times.
✓ Branch 1 taken 39890 times.
64970 if(showsubscr)
4974 {
4975 39890 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4976
3/4
✓ Branch 0 taken 39890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 39140 times.
39890 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4977 {
4978 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4979 750 }
4980 39890 }
4981
4982 64970 advanceframe(true);
4983
4984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64970 times.
64970 if(Quit)
4985 break;
4986
4987 64970 --fcnt;
4988 }
4989 2168 }
4990
4991 1013 void openscreen(int32_t shape)
4992 {
4993 1013 reset_pal_cycling();
4994 1013 black_opening_count=0;
4995
4996
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 913 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
1013 if(COOLSCROLL || shape>-1)
4997 {
4998 913 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4999 913 return;
5000 }
5001 else
5002 {
5003 100 Hero.setDontDraw(true);
5004 100 show_subscreen_dmap_dots=false;
5005 100 show_subscreen_numbers=false;
5006 // show_subscreen_items=false;
5007 100 show_subscreen_life=false;
5008 }
5009
5010 100 int32_t x=128;
5011
5012 100 FFCore.warpScriptCheck();
5013
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8000 times.
8100 for(int32_t i=0; i<80; i++)
5014 {
5015 8000 draw_screen(tmpscr);
5016 //? draw_screen already draws the subscreen -DD
5017 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5018 8000 x=128-(((i*128/80)/8)*8);
5019
5020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(x>0)
5021 {
5022 8000 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5023 8000 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5024 8000 }
5025
5026 8000 advanceframe(true);
5027
5028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(Quit)
5029 {
5030 break;
5031 }
5032 8000 }
5033
5034 100 Hero.setDontDraw(false);
5035 100 show_subscreen_items=true;
5036 100 show_subscreen_dmap_dots=true;
5037 1013 }
5038
5039 void closescreen(int32_t shape)
5040 {
5041 reset_pal_cycling();
5042 black_opening_count=0;
5043
5044 if(COOLSCROLL || shape>-1)
5045 {
5046 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5047 return;
5048 }
5049 else
5050 {
5051 Hero.setDontDraw(true);
5052 show_subscreen_dmap_dots=false;
5053 show_subscreen_numbers=false;
5054 // show_subscreen_items=false;
5055 show_subscreen_life=false;
5056 }
5057
5058 int32_t x=128;
5059
5060 FFCore.warpScriptCheck();
5061 for(int32_t i=79; i>=0; --i)
5062 {
5063 draw_screen(tmpscr);
5064 //? draw_screen already draws the subscreen -DD
5065 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5066 x=128-(((i*128/80)/8)*8);
5067
5068 if(x>0)
5069 {
5070 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5071 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5072 }
5073
5074 advanceframe(true);
5075
5076 if(Quit)
5077 {
5078 break;
5079 }
5080 }
5081
5082 Hero.setDontDraw(false);
5083 show_subscreen_items=true;
5084 show_subscreen_dmap_dots=true;
5085 }
5086
5087 179 int32_t TriforceCount()
5088 {
5089 179 int32_t c=0;
5090
5091
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5092
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5093 1044 ++c;
5094
5095 179 return c;
5096 }
5097
5098 int32_t onCustomGame()
5099 {
5100 int32_t file = getsaveslot();
5101
5102 if(file < 0)
5103 return D_O_K;
5104
5105 bool ret = (custom_game(file)!=0);
5106 return ret ? D_CLOSE : D_O_K;
5107 }
5108
5109 int32_t onContinue()
5110 {
5111 return D_CLOSE;
5112 }
5113
5114 int32_t onEsc() // Unused?? -L
5115 {
5116 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5117 }
5118
5119 int32_t onVsync()
5120 {
5121 Throttlefps = !Throttlefps;
5122 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5123 return D_O_K;
5124 }
5125
5126 int32_t onWinPosSave()
5127 {
5128 SaveWinPos = !SaveWinPos;
5129 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5130 return D_O_K;
5131 }
5132 int32_t onIntegerScaling()
5133 {
5134 scaleForceInteger = !scaleForceInteger;
5135 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5136 return D_O_K;
5137 }
5138 int32_t onStretchGame()
5139 {
5140 stretchGame = !stretchGame;
5141 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5142 return D_O_K;
5143 }
5144
5145 int32_t onClickToFreeze()
5146 {
5147 ClickToFreeze = !ClickToFreeze;
5148 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5149 return D_O_K;
5150 }
5151
5152 int32_t OnSaveZCConfig()
5153 {
5154 if(jwin_alert3(
5155 "Save Configuration",
5156 "Are you sure that you wish to save your present configuration settings?",
5157 "This will overwrite your prior settings!",
5158 NULL,
5159 "&Yes",
5160 "&No",
5161 NULL,
5162 'y',
5163 'n',
5164 0,
5165 get_zc_font(font_lfont)) == 1)
5166 {
5167 save_game_configs();
5168 return D_O_K;
5169 }
5170 else return D_O_K;
5171 }
5172
5173 int32_t OnnClearQuestDir()
5174 {
5175 auto current_path = fs::current_path() / "quests";
5176 if(jwin_alert3(
5177 "Clear Current Directory Cache",
5178 "Are you sure that you wish to reset where ZC Player looks for quests?",
5179 fmt::format("The new directory will be: {}", current_path.string()).c_str(),
5180 NULL,
5181 "&Yes",
5182 "&No",
5183 NULL,
5184 'y',
5185 'n',
5186 0,
5187 get_zc_font(font_lfont)) == 1)
5188 {
5189 zc_set_config("zeldadx","quest_dir","quests");
5190 flush_config_file();
5191 strcpy(qstdir,"quests");
5192 #ifdef __EMSCRIPTEN__
5193 em_sync_fs();
5194 #endif
5195 return D_O_K;
5196 }
5197 else return D_O_K;
5198 }
5199
5200
5201 int32_t onConsoleZASM()
5202 {
5203 if ( !zasm_debugger )
5204 {
5205 AlertDialog("WARNING: ZASM Debugger",
5206 "Enabling this will open the ZASM Debugger Console"
5207 "\nThis will likely grind ZC to a halt with lag."
5208 "\nTo make any use of this, it is suggested that you read"
5209 "\nthe documentation for 'void Breakpoint(char[] string);'"
5210 " in 'ZScript_Additions.txt'"
5211 "\nThis is not recommended for normal users,"
5212 " and is only intended for ZC developers,"
5213 "\nor quest developers coding directly in ZASM"
5214 "\nAre you sure that you wish to open the ZASM Debugger?",
5215 [&](bool ret,bool)
5216 {
5217 if(ret)
5218 {
5219 FFCore.ZASMPrint(true);
5220 }
5221 }).show();
5222 return D_O_K;
5223 }
5224 else
5225 {
5226 FFCore.ZASMPrint(false);
5227 return D_O_K;
5228 }
5229 }
5230
5231
5232 int32_t onConsoleZScript()
5233 {
5234 if ( !zscript_debugger )
5235 {
5236 AlertDialog("ZScript Debugger",
5237 "Enabling this will open the ZScript Debugger Console"
5238 "\nThis will display any messages logged by scripts,"
5239 " including script errors."
5240 "\nAre you sure that you wish to open the ZScript Debugger?",
5241 [&](bool ret,bool)
5242 {
5243 if(ret)
5244 {
5245 FFCore.ZScriptConsole(true);
5246 }
5247 }).show();
5248 return D_O_K;
5249 }
5250 else
5251 {
5252 FFCore.ZScriptConsole(false);
5253 return D_O_K;
5254 }
5255 }
5256
5257 int32_t onClrConsoleOnReload()
5258 {
5259 clearConsoleOnReload = !clearConsoleOnReload;
5260 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5261 return D_O_K;
5262 }
5263 int32_t onClrConsoleOnLoad()
5264 {
5265 clearConsoleOnLoad = !clearConsoleOnLoad;
5266 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5267 return D_O_K;
5268 }
5269
5270
5271 int32_t onFrameSkip()
5272 {
5273 FrameSkip = !FrameSkip;
5274 return D_O_K;
5275 }
5276
5277 int32_t onSaveDragResize()
5278 {
5279 SaveDragResize = !SaveDragResize;
5280 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5281 return D_O_K;
5282 }
5283
5284 int32_t onDragAspect()
5285 {
5286 DragAspect = !DragAspect;
5287 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5288 return D_O_K;
5289 }
5290
5291 int32_t onTransLayers()
5292 {
5293 TransLayers = !TransLayers;
5294 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5295 return D_O_K;
5296 }
5297
5298 int32_t onNESquit()
5299 {
5300 NESquit = !NESquit;
5301 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5302 return D_O_K;
5303 }
5304
5305 int32_t onVolKeys()
5306 {
5307 volkeys = !volkeys;
5308 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5309 return D_O_K;
5310 }
5311
5312 int32_t onShowFPS()
5313 {
5314 ShowFPS = !ShowFPS;
5315 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5316 return D_O_K;
5317 }
5318
5319 1095890898 bool is_Fkey(int32_t k)
5320 {
5321
2/2
✓ Branch 0 taken 111446532 times.
✓ Branch 1 taken 984444366 times.
1095890898 switch(k)
5322 {
5323 case KEY_F1:
5324 case KEY_F2:
5325 case KEY_F3:
5326 case KEY_F4:
5327 case KEY_F5:
5328 case KEY_F6:
5329 case KEY_F7:
5330 case KEY_F8:
5331 case KEY_F9:
5332 case KEY_F10:
5333 case KEY_F11:
5334 case KEY_F12:
5335 111446532 return true;
5336 }
5337
5338 984444366 return false;
5339 1095890898 }
5340
5341 void kb_getkey(DIALOG *d);
5342
5343 //Used by all keyboard key settings dialogues.
5344 void kb_clearjoystick(DIALOG *d)
5345 {
5346 d->flags|=D_SELECTED;
5347
5348 jwin_button_proc(MSG_DRAW,d,0);
5349 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5350 // text_mode(vc(11));
5351 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5352 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5353
5354 update_hw_screen(true);
5355
5356 clear_keybuf();
5357 int32_t k = next_press_key();
5358 clear_keybuf();
5359
5360 //shnarf
5361 //47=f1
5362 //59=esc
5363 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5364 // *((int32_t*)d->dp3) = k;
5365 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5366
5367
5368 d->flags&=~D_SELECTED;
5369 }
5370
5371 //Clears key to 0.
5372 //Used by all keyboard key settings dialogues.
5373 void kb_clearkey(DIALOG *d);
5374
5375 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5376 {
5377 switch(msg)
5378 {
5379 case MSG_KEY:
5380 case MSG_CLICK:
5381
5382 kb_clearjoystick(d);
5383
5384 while(gui_mouse_b())
5385 {
5386 clear_keybuf();
5387 rest(1);
5388 }
5389
5390 return D_REDRAW;
5391 }
5392
5393 return jwin_button_proc(msg,d,c);
5394 }
5395
5396 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5397 //Only used in keyboard settings dialogues to clear keys.
5398 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5399
5400 int32_t j_getbtn(DIALOG *d)
5401 {
5402 d->flags|=D_SELECTED;
5403 jwin_button_proc(MSG_DRAW,d,0);
5404 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5405 // text_mode(vc(11));
5406 int32_t y = screen->h/2 - 12;
5407 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5408 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5409 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5410
5411 update_hw_screen(true);
5412
5413 int32_t b = next_joy_input(true);
5414 if (b == -2)
5415 return D_CLOSE;
5416
5417 if(b>=0)
5418 *((int32_t*)d->dp3) = b;
5419
5420 d->flags&=~D_SELECTED;
5421
5422 if (player)
5423 player->joy_on = TRUE;
5424
5425 return D_O_K;
5426 }
5427
5428 void j_getstick(DIALOG *d)
5429 {
5430 d->flags|=D_SELECTED;
5431 jwin_button_proc(MSG_DRAW,d,0);
5432 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5433 // text_mode(vc(11));
5434 int32_t y = screen->h/2 - 12;
5435 textout_centre_ex(screen, font, "Move a stick (or DPAD)", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5436 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5437 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5438
5439 update_hw_screen(true);
5440
5441 int32_t b = next_joy_input(false);
5442
5443 if(b>=0)
5444 *((int32_t*)d->dp3) = b;
5445
5446 d->flags&=~D_SELECTED;
5447
5448 if (player)
5449 player->joy_on = TRUE;
5450 }
5451
5452 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5453 {
5454 switch(msg)
5455 {
5456 case MSG_KEY:
5457 case MSG_CLICK:
5458
5459 int ret = j_getbtn(d);
5460 if (ret != D_O_K)
5461 return ret;
5462
5463 while(gui_mouse_b()) {
5464 rest(1);
5465 clear_keybuf();
5466 }
5467
5468 return D_REDRAW;
5469 }
5470
5471 return jwin_button_proc(msg,d,c);
5472 }
5473
5474 int32_t d_jstick_proc(int32_t msg,DIALOG *d,int32_t c)
5475 {
5476 switch(msg)
5477 {
5478 case MSG_KEY:
5479 case MSG_CLICK:
5480
5481 j_getstick(d);
5482
5483 while(gui_mouse_b()) {
5484 rest(1);
5485 clear_keybuf();
5486 }
5487
5488 return D_REDRAW;
5489 }
5490
5491 return jwin_button_proc(msg,d,c);
5492 }
5493
5494 //shnarf
5495 extern const char *key_str[];
5496 std::string get_keystr(int key);
5497
5498 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5499 //extern int32_t zcmusic_bufsz;
5500
5501 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5502 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80],
5503 str_primary_stick[80], str_secondary_stick[80];
5504
5505 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5506 {
5507 //these are here to bypass compiler warnings about unused arguments
5508 c=c;
5509
5510 if (d->w == 1)
5511 {
5512 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
5513 {
5514 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
5515 return D_CLOSE;
5516 }
5517 }
5518
5519 if(msg==MSG_DRAW)
5520 {
5521 switch(d->w)
5522 {
5523 case 0:
5524 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5525 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5526 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5527 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5528 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5529 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5530 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5531 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5532 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5533 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5534 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5535 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5536 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5537 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5538 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5539 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5540 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5541 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5542 break;
5543
5544 case 1:
5545 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5546 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5547 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5548 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5549 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5550 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5551 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5552 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5553 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5554 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5555 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5556 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5557 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5558 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5559 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5560 sprintf(str_primary_stick,"%03d\n%s",js_stick_1_x_stick,joystick_name(js_stick_1_x_stick));
5561 sprintf(str_secondary_stick,"%03d\n%s",js_stick_2_x_stick,joystick_name(js_stick_2_x_stick));
5562 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5563 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5564 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5565 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5566 break;
5567
5568 case 2:
5569 sprintf(str_a," %3d",midi_volume);
5570 sprintf(str_b," %3d",digi_volume);
5571 sprintf(str_l," %3d",emusic_volume);
5572 sprintf(str_m," %3dKB",zcmusic_bufsz);
5573 sprintf(str_r," %3d",sfx_volume);
5574 strcpy(str_s,pan_str[pan_style]);
5575 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5576 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5577 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5578 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5579 break;
5580 }
5581 }
5582
5583 return D_O_K;
5584 }
5585
5586 int32_t set_vol(void *dp3, int32_t d2)
5587 {
5588 switch(((int32_t*)dp3)[0])
5589 {
5590 case 0:
5591 midi_volume = zc_min(d2<<3,255);
5592 break;
5593
5594 case 1:
5595 digi_volume = zc_min(d2<<3,255);
5596 break;
5597
5598 case 2:
5599 emusic_volume = zc_min(d2<<3,255);
5600 break;
5601
5602 case 3:
5603 sfx_volume = zc_min(d2<<3,255);
5604 break;
5605 }
5606
5607 // text_mode(vc(11));
5608 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5609 return D_O_K;
5610 }
5611
5612 int32_t set_pan(void *dp3, int32_t d2)
5613 {
5614 pan_style = vbound(d2,0,3);
5615 // text_mode(vc(11));
5616 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5617 return D_O_K;
5618 }
5619
5620 int32_t set_buf(void *dp3, int32_t d2)
5621 {
5622 // text_mode(vc(11));
5623 zcmusic_bufsz = d2 + 1;
5624 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5625 return D_O_K;
5626 }
5627
5628 static int32_t gamepad_joys_list[] =
5629 {
5630 61,
5631 -1
5632 };
5633
5634 static int32_t gamepad_btn_list[] =
5635 {
5636 6,
5637 7,8,9,10,11,12,13,14,15,16,17,
5638 18,19,20,21,22,23,24,25,26,27,28,
5639 29,30,31,32,33,34,35,36,37,38,39,
5640 -1
5641 };
5642
5643 static int32_t gamepad_dirs_list[] =
5644 {
5645 40,41,42,43,
5646 44,45,46,47,
5647 48,49,50,51,
5648 52,53,54,55,
5649 56,57,58,59,
5650 60,
5651 -1
5652 };
5653
5654 static TABPANEL gamepad_tabs[] =
5655 {
5656 // (text)
5657 { (char *)"Controllers", D_SELECTED, gamepad_joys_list, 0, NULL },
5658 { (char *)"Buttons", 0, gamepad_btn_list, 0, NULL },
5659 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5660 { NULL, 0, NULL, 0, NULL }
5661 };
5662
5663 const char *joy_list(int32_t index, int32_t *list_size)
5664 {
5665 if (index == -1)
5666 {
5667 *list_size = al_get_num_joysticks();
5668 return NULL;
5669 }
5670
5671 ALLEGRO_JOYSTICK* joy = al_get_joystick(index);
5672 if (!joy)
5673 {
5674 return "?";
5675 }
5676
5677 return al_get_joystick_name(joy);
5678 }
5679
5680 117 static ListData joy__list(joy_list, &font);
5681
5682 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c)
5683 {
5684 int32_t d2 = d->d2;
5685 int32_t ret = jwin_droplist_proc(msg,d,c);
5686
5687 if(d2!=d->d2)
5688 {
5689 joystick_index = d->d2;
5690 ret |= D_REDRAW_ALL;
5691 }
5692
5693 return ret;
5694 }
5695
5696 static DIALOG gamepad_dlg[] =
5697 {
5698 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5699 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5700 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5701 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5702 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5703 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5704 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5705 // 6
5706 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5707 // 7
5708 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5709 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5710 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5711 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5712 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5713 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5714 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5715 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5716 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5717 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5718 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5719 // 18
5720 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5721 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5722 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5723 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5724 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5725 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5726 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5727 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5728 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5729 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5730 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5731 // 29
5732 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5733 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5734 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5735 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5736 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5737 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5738 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5739 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5740 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5741 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5742 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5743 // 40
5744 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5745 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5746 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5747 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5748 // 44
5749 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5750 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5751 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5752 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5753 // 48
5754 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5755 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5756 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5757 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5758 // 52
5759 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5760 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5761 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5762 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5763 // 56
5764 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Primary: Use Analog Stick (Ignore above and use below instead)", NULL, NULL },
5765 { d_jstick_proc, 22, 165, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Primary", NULL, &js_stick_1_x_stick },
5766 { d_jstick_proc, 22, 195, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Secondary", NULL, &js_stick_2_x_stick },
5767 { jwin_text_proc, 90, 165, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_primary_stick, NULL, NULL },
5768 { jwin_text_proc, 90, 195, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_secondary_stick, NULL, NULL },
5769
5770 // 61
5771 { d_joylist_proc, 22, 62, 150, 16, 0, 0, 0, 0, 0, 0, (void *) &joy__list, NULL, NULL },
5772
5773 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5774 };
5775
5776 static int32_t keyboard_keys_list[] =
5777 {
5778 6,7,8,9,10,
5779 11,12,13,14,15,16,17,18,19,20,
5780 21,22,23,24,25,26,27,28,29,30,
5781 31,32,33,34,35,36,37,38,39,40,
5782 -1
5783 };
5784
5785 static int32_t keyboard_dirs_list[] =
5786 {
5787 41,42,43,44,
5788 45,46,47,48,
5789 49,50,51,52,
5790 53,54,55,56,
5791 -1
5792 };
5793
5794 static int32_t keyboard_mods_list[] =
5795 {
5796 57,58,59,60,
5797 61,62,63,64,
5798 65,66,67,68,
5799 69,70,71,72,
5800 -1
5801 };
5802
5803 static TABPANEL keyboard_control_tabs[] =
5804 {
5805 // (text)
5806 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5807 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5808 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5809 { NULL, 0, NULL, 0, NULL }
5810 };
5811
5812 static DIALOG keyboard_control_dlg[] =
5813 {
5814 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5815 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5816 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5817 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5818 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5819 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5820 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5821 // Keys
5822 // 6
5823 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5824 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5825 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5826 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5827 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5828 // 11
5829 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5830 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5831 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5832 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5833 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5834 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5835 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5836 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5837 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5838 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5839 // 21
5840 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5841 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5842 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5843 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5844 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5845 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5846 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5847 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5848 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5849 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5850 // 31
5851 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5852 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5853 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5854 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5855 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5856 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5857 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5858 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5859 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5860 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5861 // Dirs
5862 // 41
5863 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5864 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5865 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5866 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5867 // 45
5868 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5869 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5870 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5871 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5872 // 49
5873 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5874 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5875 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5876 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5877 // 53
5878 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5879 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5880 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5881 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5882 // Mods
5883 // 57
5884 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5885 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5886 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5887 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5888 // 61
5889 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5890 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5891 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5892 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5893 // 65
5894 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5895 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5896 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5897 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5898 // 69
5899 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5900 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5901 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5902 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5903 // 73
5904 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5905 };
5906
5907 /*
5908 int32_t midi_dp[3] = {0,147,104};
5909 int32_t digi_dp[3] = {1,147,120};
5910 int32_t pan_dp[3] = {0,147,136};
5911 int32_t buf_dp[3] = {0,147,152};
5912 */
5913 int32_t midi_dp[3] = {0,0,0};
5914 int32_t digi_dp[3] = {1,0,0};
5915 int32_t emus_dp[3] = {2,0,0};
5916 int32_t buf_dp[3] = {0,0,0};
5917 int32_t sfx_dp[3] = {3,0,0};
5918 int32_t pan_dp[3] = {0,0,0};
5919
5920 static DIALOG sound_dlg[] =
5921 {
5922 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5923 117 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5924 117 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5925 117 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5926 117 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5927 117 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5928 117 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5929 117 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5930 117 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5931 117 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5932 117 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5933 // 10
5934 117 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5935 117 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5936 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5937 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5938 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5939 117 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5940 117 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5941 117 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5942 117 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5943 117 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5944 //20
5945 117 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5946 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5947 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5948 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5949 117 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5950 117 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5951 117 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5952 117 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5953 117 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5954 117 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5955 //30
5956 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5957 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5958 117 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5959 117 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5960 };
5961
5962 char zc_builddate[80];
5963 char zc_aboutstr[80];
5964
5965 static DIALOG about_dlg[] =
5966 {
5967 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5968 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5969 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5970 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5971 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5972 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5973 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5974 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5975 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5976 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5977 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5978 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5979 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5980 };
5981
5982
5983 static DIALOG quest_dlg[] =
5984 {
5985 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5986 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5987 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5988 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5989 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5990 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5991 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5992 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5993 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5994 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5995 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5996 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5997 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5998 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5999 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6000 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6001 };
6002
6003 static DIALOG triforce_dlg[] =
6004 {
6005 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6006 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6007 // 1
6008 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6009 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6010 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6011 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6012 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6013 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6014 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6015 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6016 // 9
6017 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6018 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6019 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6020 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6021 };
6022
6023 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6024 {
6025 go();
6026 int32_t ret=0;
6027 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6028 comeback();
6029 return ret != 0;
6030 }
6031
6032
6033 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6034 {
6035 if(def!=modulepath)
6036 strcpy(modulepath,def);
6037
6038 if(!usefilename)
6039 {
6040 int32_t i=(int32_t)strlen(modulepath);
6041
6042 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6043 modulepath[i--]=0;
6044 }
6045
6046 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6047 int32_t ret=0;
6048 int32_t sel=0;
6049
6050 if(list==NULL)
6051 {
6052 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
6053 }
6054 else
6055 {
6056 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
6057 }
6058
6059 return ret!=0;
6060 }
6061
6062 int32_t onToggleRecordingNewSaves()
6063 {
6064 if (zc_get_config("zeldadx", "replay_new_saves", false))
6065 {
6066 zc_set_config("zeldadx", "replay_new_saves", false);
6067 }
6068 else
6069 {
6070 zc_set_config("zeldadx", "replay_new_saves", true);
6071 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6072 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6073 }
6074 return D_O_K;
6075 }
6076
6077 int32_t onToggleSnapshotAllFrames()
6078 {
6079 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6080 return D_O_K;
6081 }
6082
6083 int32_t onStopReplayOrRecord()
6084 {
6085 if (replay_is_replaying())
6086 {
6087 replay_quit();
6088 }
6089 else if (replay_get_mode() == ReplayMode::Record)
6090 {
6091 if (!replay_get_meta_bool("test_mode"))
6092 {
6093 jwin_alert("Recording", "You cannot stop recording a save file.",
6094 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6095 return D_CLOSE;
6096 }
6097
6098 if (jwin_alert("Stop Recording",
6099 "Save replay to disk and stop recording?",
6100 "This will stop the recording.",
6101 NULL,
6102 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6103 return D_CLOSE;
6104
6105 replay_save();
6106 replay_stop();
6107 }
6108 return D_O_K;
6109 }
6110
6111 static int32_t handle_on_load_replay(ReplayMode mode)
6112 {
6113 if (Playing)
6114 {
6115 if (jwin_alert("Replay - Warning!",
6116 "Loading a replay will exit the current game.",
6117 "All unsaved progress will be lost.",
6118 "Do you wish to continue?",
6119 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6120 return D_CLOSE;
6121 }
6122
6123 std::string mode_string = replay_mode_to_string(mode);
6124 mode_string[0] = std::toupper(mode_string[0]);
6125
6126 std::string line_1 = "Select a replay file to play back.";
6127 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6128 std::string line_3 = "You can stop the replay and take over manually any time.";
6129 if (mode == ReplayMode::Update)
6130 {
6131 line_1 = "Select a replay file to update.";
6132 line_2 = "WARNING: be sure to back up the zplay file";
6133 line_3 = "and verify that the updated replay works as expected!";
6134 }
6135
6136 if (jwin_alert(mode_string.c_str(),
6137 line_1.c_str(),
6138 line_2.c_str(),
6139 line_3.c_str(),
6140 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6141 {
6142 char replay_path[2048];
6143 strcpy(replay_path, "replays/");
6144 if (jwin_file_select_ex(
6145 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6146 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6147 return D_CLOSE;
6148
6149 replay_quit();
6150 load_replay_file_deferred(mode, replay_path);
6151 Quit = qRESET;
6152 return D_CLOSE;
6153 }
6154 return D_O_K;
6155 }
6156
6157 int32_t onLoadReplay()
6158 {
6159 return handle_on_load_replay(ReplayMode::Replay);
6160 }
6161
6162 int32_t onLoadReplayAssert()
6163 {
6164 return handle_on_load_replay(ReplayMode::Assert);
6165 }
6166
6167 int32_t onLoadReplayUpdate()
6168 {
6169 return handle_on_load_replay(ReplayMode::Update);
6170 }
6171
6172 int32_t onSaveReplay()
6173 {
6174 if (replay_get_mode() == ReplayMode::Record)
6175 {
6176 if (!replay_get_meta_bool("test_mode"))
6177 {
6178 if (jwin_alert("Save Replay",
6179 "This will save a copy of the replay up to this point.",
6180 "The official replay file will be untouched.",
6181 "Do you wish to continue?",
6182 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6183 return D_CLOSE;
6184
6185 char replay_path[2048];
6186 strcpy(replay_path, replay_get_replay_path().string().c_str());
6187 if (jwin_file_select_ex(
6188 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6189 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6190 return D_CLOSE;
6191
6192 if (fileexists(replay_path))
6193 {
6194 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6195 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6196 return D_CLOSE;
6197 }
6198
6199 replay_save(replay_path);
6200 }
6201 else
6202 {
6203 replay_save();
6204 }
6205 }
6206 return D_O_K;
6207 }
6208
6209 static MENU replay_menu[] =
6210 {
6211 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6212 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6213 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6214 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6215 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6216 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6217 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6218
6219 { NULL, NULL, NULL, 0, NULL }
6220 };
6221
6222 static DIALOG credits_dlg[] =
6223 {
6224 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6225 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6226 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6227 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6228 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6229 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6230 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6231 };
6232
6233 117 static ListData dmap_list(dmaplist, &font);
6234
6235 static DIALOG goto_dlg[] =
6236 {
6237 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6238 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6239 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6240 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6241 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6242 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6243 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6244 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6245 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6246 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6247 };
6248
6249 int32_t onGoTo()
6250 {
6251 bool music = false;
6252 music = music;
6253 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6254
6255 goto_dlg[0].dp2=get_zc_font(font_lfont);
6256 goto_dlg[4].d2=cheat_goto_dmap;
6257 goto_dlg[6].dp=cheat_goto_screen_str;
6258
6259 clear_keybuf();
6260
6261 large_dialog(goto_dlg);
6262
6263 if(do_zqdialog(goto_dlg,4)==1)
6264 {
6265 // dmap, screen
6266 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6267 };
6268
6269 return D_O_K;
6270 }
6271
6272 int32_t onGoToComplete()
6273 {
6274 if(!Playing)
6275 {
6276 return D_O_K;
6277 }
6278
6279 enter_sys_pal();
6280 music_pause();
6281 pause_all_sfx();
6282 onGoTo();
6283 eat_buttons();
6284
6285 zc_readrawkey(KEY_ESC);
6286
6287 exit_sys_pal();
6288 music_resume();
6289 resume_all_sfx();
6290 return D_O_K;
6291 }
6292
6293 int32_t onCredits()
6294 {
6295 return D_O_K;
6296 }
6297
6298 const char *midilist(int32_t index, int32_t *list_size)
6299 {
6300 if(index<0)
6301 {
6302 *list_size=0;
6303
6304 for(int32_t i=0; i<MAXMIDIS; i++)
6305 if(tunes[i].data)
6306 ++(*list_size);
6307
6308 return NULL;
6309 }
6310
6311 int32_t i=0,m=0;
6312
6313 while(m<=index && i<=MAXMIDIS)
6314 {
6315 if(tunes[i].data)
6316 ++m;
6317
6318 ++i;
6319 }
6320
6321 --i;
6322
6323 if(i==MAXMIDIS && m<index)
6324 return "(null)";
6325
6326 return tunes[i].title;
6327 }
6328
6329 /* ------- MIDI info stuff -------- */
6330
6331 char *text;
6332 midi_info *zmi;
6333 bool dialog_running;
6334 bool listening;
6335
6336 void get_info(int32_t index);
6337
6338 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6339 {
6340 int32_t d2 = d->d2;
6341 int32_t ret = jwin_droplist_proc(msg,d,c);
6342
6343 if(d2!=d->d2)
6344 {
6345 get_info(d->d2);
6346 }
6347
6348 return ret;
6349 }
6350
6351 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6352 {
6353 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6354
6355 int32_t ret = jwin_button_proc(msg,d,c);
6356
6357 if(ret == D_CLOSE)
6358 {
6359 // get current midi index
6360 int32_t index = (d+(d->d1))->d2;
6361 int32_t i=0, m=0;
6362
6363 while(m<=index && i<=MAXMIDIS)
6364 {
6365 if(tunes[i].data)
6366 ++m;
6367
6368 ++i;
6369 }
6370
6371 --i;
6372 jukebox(i);
6373 listening = true;
6374 ret = D_O_K;
6375 }
6376
6377 return ret;
6378 }
6379
6380 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6381 {
6382 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6383
6384 int32_t ret = jwin_button_proc(msg,d,c);
6385
6386 if(ret == D_CLOSE)
6387 {
6388 // get current midi index
6389 int32_t index = (d+(d->d1))->d2;
6390 int32_t i=0, m=0;
6391
6392 while(m<=index && i<=MAXMIDIS)
6393 {
6394 if(tunes[i].data)
6395 ++m;
6396
6397 ++i;
6398 }
6399
6400 --i;
6401
6402 // get file name
6403
6404 int32_t sel=0;
6405 //struct ffblk f;
6406 char title[40] = "Save MIDI: ";
6407 char fname[2048];
6408 memset(fname,0,2048);
6409 static EXT_LIST list[] =
6410 {
6411 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6412 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6413 { NULL, NULL }
6414 };
6415
6416 strcpy(title+11, tunes[i].title);
6417 title[39] = '\0';
6418
6419 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6420 goto done;
6421
6422 if(exists(fname))
6423 {
6424 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6425 goto done;
6426 }
6427
6428 // save midi i
6429
6430 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6431 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6432
6433 done:
6434 chop_path(fname);
6435 ret = D_REDRAW;
6436 }
6437
6438 return ret;
6439 }
6440
6441 117 static ListData midi_list(midilist, &font);
6442
6443 static DIALOG midi_dlg[] =
6444 {
6445 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6446 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6447 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6448 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6449 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6450 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6451 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6452 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6453 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6454 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6455 };
6456
6457 void get_info(int32_t index)
6458 {
6459 int32_t i=0, m=0;
6460
6461 while(m<=index && i<=MAXMIDIS)
6462 {
6463 if(tunes[i].data)
6464 ++m;
6465
6466 ++i;
6467 }
6468
6469 --i;
6470
6471 if(i==MAXMIDIS && m<index)
6472 strcpy(text,"(null)");
6473 else
6474 {
6475 get_midi_info((MIDI*)tunes[i].data,zmi);
6476 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6477 }
6478
6479 midi_dlg[0].dp2=get_zc_font(font_lfont);
6480 midi_dlg[3].dp = text;
6481 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6482 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6483
6484 if(dialog_running)
6485 {
6486 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6487 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6488 }
6489 }
6490
6491 int32_t onMIDICredits()
6492 {
6493 text = (char*)malloc(4096);
6494 zmi = (midi_info*)malloc(sizeof(midi_info));
6495
6496 if(!text || !zmi)
6497 {
6498 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6499 return D_O_K;
6500 }
6501
6502 bool do_pause_midi = midi_pos >= 0 && currmidi;
6503 auto restore_midi = currmidi;
6504 if(do_pause_midi)
6505 {
6506 paused_midi_pos = midi_pos;
6507 stop_midi();
6508 midi_suspended = midissuspHALTED;
6509 }
6510
6511 midi_dlg[0].dp2=get_zc_font(font_lfont);
6512 midi_dlg[2].d1 = 0;
6513 midi_dlg[2].d2 = 0;
6514 midi_dlg[4].flags = D_EXIT;
6515 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6516
6517 listening = false;
6518 dialog_running=false;
6519 get_info(0);
6520
6521 dialog_running=true;
6522
6523 large_dialog(midi_dlg);
6524
6525 do_zqdialog(midi_dlg,0);
6526 dialog_running=false;
6527
6528 if(listening)
6529 music_stop();
6530
6531 if(do_pause_midi)
6532 {
6533 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6534 midi_suspended = midissuspRESUME;
6535 currmidi = restore_midi;
6536 midi_pos = paused_midi_pos;
6537 }
6538
6539 if(text) free(text);
6540 if(zmi) free(zmi);
6541 return D_O_K;
6542 }
6543
6544 int32_t onAbout()
6545 {
6546 char buf1[80]={0};
6547 std::ostringstream oss;
6548 sprintf(buf1,"%s, Version: %s", ZC_PLAYER_NAME,ZC_PLAYER_V);
6549 oss << buf1 << '\n';
6550 sprintf(buf1, "%s", ALPHA_VER_STR);
6551 oss << buf1 << '\n';
6552 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6553 oss << buf1 << '\n';
6554 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6555 oss << buf1 << '\n';
6556 sprintf(buf1, "Tag: %s", getReleaseTag());
6557 oss << buf1 << '\n';
6558
6559 InfoDialog("About ZC", oss.str()).show();
6560 return D_O_K;
6561 }
6562
6563 int32_t onQuest()
6564 {
6565 char fname[100];
6566 strcpy(fname, get_filename(qstpath));
6567 quest_dlg[0].dp2=get_zc_font(font_lfont);
6568 quest_dlg[1].dp = fname;
6569
6570 if(QHeader.quest_number==0)
6571 sprintf(str_a,"Custom");
6572 else
6573 sprintf(str_a,"%d",QHeader.quest_number);
6574
6575 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6576
6577 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6578 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6579
6580 large_dialog(quest_dlg);
6581
6582 do_zqdialog(quest_dlg, 0);
6583 return D_O_K;
6584 }
6585
6586 void call_vidmode_dlg();
6587 int32_t onVidMode()
6588 {
6589 call_vidmode_dlg();
6590 return D_O_K;
6591 }
6592
6593 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6594 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6595 //Added an extra statement, so that if the key is cleared to 0, the cleared
6596 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6597
6598 void load_ukeys(int32_t* arr)
6599 {
6600 arr[ukey_a] = Akey;
6601 arr[ukey_b] = Bkey;
6602 arr[ukey_s] = Skey;
6603 arr[ukey_l] = Lkey;
6604 arr[ukey_r] = Rkey;
6605 arr[ukey_p] = Pkey;
6606 arr[ukey_ex1] = Exkey1;
6607 arr[ukey_ex2] = Exkey2;
6608 arr[ukey_ex3] = Exkey3;
6609 arr[ukey_ex4] = Exkey4;
6610 arr[ukey_du] = DUkey;
6611 arr[ukey_dd] = DDkey;
6612 arr[ukey_dl] = DLkey;
6613 arr[ukey_dr] = DRkey;
6614 arr[ukey_mod1a] = cheat_modifier_keys[0];
6615 arr[ukey_mod1b] = cheat_modifier_keys[1];
6616 arr[ukey_mod2a] = cheat_modifier_keys[2];
6617 arr[ukey_mod2b] = cheat_modifier_keys[3];
6618 };
6619
6620 static const char* ukey_names[] = {
6621 "A", "B", "Start", "L", "R", "Map",
6622 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6623 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6624 "Cheat Mod R1", "Cheat Mod R2",
6625 };
6626 std::string get_ukey_name(int32_t k)
6627 {
6628 if (k < num_ukey) return ukey_names[k];
6629 return "";
6630 }
6631
6632 int32_t onKeyboard()
6633 {
6634 int32_t a = Akey;
6635 int32_t b = Bkey;
6636 int32_t s = Skey;
6637 int32_t l = Lkey;
6638 int32_t r = Rkey;
6639 int32_t p = Pkey;
6640 int32_t ex1 = Exkey1;
6641 int32_t ex2 = Exkey2;
6642 int32_t ex3 = Exkey3;
6643 int32_t ex4 = Exkey4;
6644 int32_t du = DUkey;
6645 int32_t dd = DDkey;
6646 int32_t dl = DLkey;
6647 int32_t dr = DRkey;
6648 int32_t mod1a = cheat_modifier_keys[0];
6649 int32_t mod1b = cheat_modifier_keys[1];
6650 int32_t mod2a = cheat_modifier_keys[2];
6651 int32_t mod2b = cheat_modifier_keys[3];
6652 bool done=false;
6653 int32_t ret;
6654
6655 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6656
6657 large_dialog(keyboard_control_dlg);
6658
6659 while(!done)
6660 {
6661 ret = do_zqdialog(keyboard_control_dlg,3);
6662
6663 if(ret==3) // OK
6664 {
6665 int32_t ukeys[num_ukey];
6666 load_ukeys(ukeys);
6667 std::vector<std::string> uniqueError;
6668 for(int32_t q = 0; q < num_ukey; ++q)
6669 {
6670 for(int32_t p = q+1; p < num_ukey; ++p)
6671 {
6672 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6673 {
6674 char buf[64];
6675 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6676 std::string str(buf);
6677 uniqueError.push_back(str);
6678 }
6679 }
6680 }
6681 if(uniqueError.size() == 0)
6682 {
6683 done = true;
6684 save_control_configs(true);
6685 }
6686 else
6687 {
6688 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6689 box_out("Cannot have duplicate keybinds!"); box_eol();
6690 for(std::vector<std::string>::iterator it = uniqueError.begin();
6691 it != uniqueError.end(); ++it)
6692 {
6693 box_out((*it).c_str()); box_eol();
6694 }
6695 box_end(true);
6696 }
6697 }
6698 else // Cancel
6699 {
6700 Akey = a;
6701 Bkey = b;
6702 Skey = s;
6703 Lkey = l;
6704 Rkey = r;
6705 Pkey = p;
6706 Exkey1 = ex1;
6707 Exkey2 = ex2;
6708 Exkey3 = ex3;
6709 Exkey4 = ex4;
6710 DUkey = du;
6711 DDkey = dd;
6712 DLkey = dl;
6713 DRkey = dr;
6714 cheat_modifier_keys[0] = mod1a;
6715 cheat_modifier_keys[1] = mod1b;
6716 cheat_modifier_keys[2] = mod2a;
6717 cheat_modifier_keys[3] = mod2b;
6718
6719 done=true;
6720 }
6721
6722 rest(1);
6723 }
6724
6725 return D_O_K;
6726 }
6727
6728 int32_t onGamepad()
6729 {
6730 if (al_get_num_joysticks() == 0)
6731 {
6732 InfoDialog("ZC", "No gamepads detected.").show();
6733 return D_O_K;
6734 }
6735
6736 int32_t a = Abtn;
6737 int32_t b = Bbtn;
6738 int32_t s = Sbtn;
6739 int32_t l = Lbtn;
6740 int32_t r = Rbtn;
6741 int32_t m = Mbtn;
6742 int32_t p = Pbtn;
6743 int32_t ex1 = Exbtn1;
6744 int32_t ex2 = Exbtn2;
6745 int32_t ex3 = Exbtn3;
6746 int32_t ex4 = Exbtn4;
6747 int32_t up = DUbtn;
6748 int32_t down = DDbtn;
6749 int32_t left = DLbtn;
6750 int32_t right = DRbtn;
6751 int32_t joy = joystick_index;
6752 int32_t stick_1 = js_stick_1_x_stick;
6753 int32_t stick_2 = js_stick_2_x_stick;
6754
6755 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6756 if(analog_movement)
6757 gamepad_dlg[56].flags|=D_SELECTED;
6758 else
6759 gamepad_dlg[56].flags&=~D_SELECTED;
6760
6761 // TODO: should use controller device GUID or name instead of index, otherwise this value is not
6762 // consistent unless exact same number of joysticks is always connected. Name is problematic b/c
6763 // xinput driver doesn't actually get a name (at least, doesn't for my Xbox controller).
6764 // TODO: should store gamepad control mappings per-controller, otherwise switching joystick
6765 // requires remapping every time.
6766 if (joystick_index >= al_get_num_joysticks())
6767 joystick_index = 0;
6768 gamepad_dlg[61].d2 = joystick_index;
6769
6770 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6771 if (!gamepad_dlg_cur_joystick)
6772 {
6773 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6774 return D_CLOSE;
6775 }
6776
6777 large_dialog(gamepad_dlg);
6778
6779 int32_t ret = do_zqdialog(gamepad_dlg,4);
6780
6781 if(ret == 4) //OK
6782 {
6783 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6784 joystick_index = gamepad_dlg[61].d2;
6785 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6786 if (!gamepad_dlg_cur_joystick)
6787 {
6788 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6789 return D_CLOSE;
6790 }
6791 js_stick_1_y_stick = js_stick_1_x_stick;
6792 js_stick_2_y_stick = js_stick_2_x_stick;
6793 save_control_configs(false);
6794 }
6795 else //Cancel
6796 {
6797 Abtn = a;
6798 Bbtn = b;
6799 Sbtn = s;
6800 Lbtn = l;
6801 Rbtn = r;
6802 Mbtn = m;
6803 Pbtn = p;
6804 Exbtn1 = ex1;
6805 Exbtn2 = ex2;
6806 Exbtn3 = ex3;
6807 Exbtn4 = ex4;
6808 DUbtn = up;
6809 DDbtn = down;
6810 DLbtn = left;
6811 DRbtn = right;
6812 joystick_index = joy;
6813 js_stick_1_x_stick = stick_1;
6814 js_stick_2_x_stick = stick_2;
6815 }
6816
6817 return D_O_K;
6818 }
6819
6820 int32_t onCheatKeys()
6821 {
6822 int32_t oldcheats[Cheat::Last][2];
6823 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6824
6825 bool done=false;
6826
6827 while(!done)
6828 {
6829 bool confirm = false;
6830 CheatKeysDialog(&confirm).show();
6831 if(confirm) // OK
6832 {
6833 std::vector<std::string> uniqueError;
6834 char buf[512];
6835 for(size_t q = 1; q < Cheat::Last; ++q)
6836 {
6837 if(cheatkeys[q][1] && !cheatkeys[q][0])
6838 {
6839 cheatkeys[q][0] = cheatkeys[q][1];
6840 cheatkeys[q][1] = 0;
6841 }
6842 }
6843 for(size_t q = 1; q < Cheat::Last; ++q)
6844 {
6845 if(!bindable_cheat((Cheat)q)) continue;
6846 for(size_t p = q+1; p < Cheat::Last; ++p)
6847 {
6848 if(!bindable_cheat((Cheat)p)) continue;
6849 for(size_t q2 = 0; q2 <= 1; ++q2)
6850 for(size_t p2 = 0; p2 <= 1; ++p2)
6851 {
6852 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6853 {
6854 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6855 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6856 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6857 get_keystr(cheatkeys[q][q2])));
6858 }
6859 }
6860 }
6861 }
6862 if(uniqueError.size() == 0)
6863 {
6864 done = true;
6865 save_cheatkeys();
6866 }
6867 else
6868 {
6869 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6870 box_out("Cannot have duplicate keybinds!"); box_eol();
6871 for(std::vector<std::string>::iterator it = uniqueError.begin();
6872 it != uniqueError.end(); ++it)
6873 {
6874 box_out((*it).c_str()); box_eol();
6875 }
6876 box_end(true);
6877 }
6878 }
6879 else // Cancel
6880 {
6881 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6882 done=true;
6883 }
6884 rest(1);
6885 }
6886
6887 return D_O_K;
6888 }
6889
6890 int32_t onSound()
6891 {
6892 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6893 {
6894 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6895 {
6896 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6897 }
6898 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6899 {
6900 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6901 }
6902 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6903 {
6904 emusic_volume = (int32_t)FFCore.usr_music_volume;
6905 }
6906 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6907 {
6908 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6909 }
6910 }
6911 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6912 {
6913 pan_style = (int32_t)FFCore.usr_panstyle;
6914 }
6915
6916 int32_t m = midi_volume;
6917 int32_t d = digi_volume;
6918 int32_t e = emusic_volume;
6919 int32_t b = zcmusic_bufsz;
6920 int32_t s = sfx_volume;
6921 int32_t p = pan_style;
6922 pan_style = vbound(pan_style,0,3);
6923
6924 sound_dlg[0].dp2=get_zc_font(font_lfont);
6925
6926 large_dialog(sound_dlg);
6927
6928 midi_dp[1] = sound_dlg[6].x;
6929 midi_dp[2] = sound_dlg[6].y;
6930 digi_dp[1] = sound_dlg[7].x;
6931 digi_dp[2] = sound_dlg[7].y;
6932 emus_dp[1] = sound_dlg[8].x;
6933 emus_dp[2] = sound_dlg[8].y;
6934 buf_dp[1] = sound_dlg[9].x;
6935 buf_dp[2] = sound_dlg[9].y;
6936 sfx_dp[1] = sound_dlg[10].x;
6937 sfx_dp[2] = sound_dlg[10].y;
6938 pan_dp[1] = sound_dlg[11].x;
6939 pan_dp[2] = sound_dlg[11].y;
6940 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6941 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6942 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6943 sound_dlg[18].d2 = zcmusic_bufsz;
6944 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6945 sound_dlg[20].d2 = pan_style;
6946
6947 int32_t ret = do_zqdialog(sound_dlg,1);
6948
6949 if(ret==2)
6950 {
6951 master_volume(digi_volume,midi_volume);
6952 if (zcmusic)
6953 zcmusic_set_volume(zcmusic, emusic_volume);
6954
6955 int32_t temp_volume = sfx_volume;
6956 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
6957 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6958 for(int32_t i=0; i<WAV_COUNT; ++i)
6959 {
6960 //allegro assertion fails when passing in -1 as voice -DD
6961 if(sfx_voice[i] > 0)
6962 voice_set_volume(sfx_voice[i], temp_volume);
6963 }
6964 zc_set_config(sfx_sect,"digi",digi_volume);
6965 zc_set_config(sfx_sect,"midi",midi_volume);
6966 zc_set_config(sfx_sect,"sfx",sfx_volume);
6967 zc_set_config(sfx_sect,"emusic",emusic_volume);
6968 zc_set_config(sfx_sect,"pan",pan_style);
6969 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6970 }
6971 else
6972 {
6973 midi_volume = m;
6974 digi_volume = d;
6975 emusic_volume = e;
6976 zcmusic_bufsz = b;
6977 sfx_volume = s;
6978 pan_style = p;
6979 }
6980
6981 return D_O_K;
6982 }
6983
6984 int32_t queding(char const* s1, char const* s2, char const* s3)
6985 {
6986 return jwin_alert("ZQuest Classic",s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6987 }
6988
6989 int32_t onQuit()
6990 {
6991 if(Playing)
6992 {
6993 int32_t ret=0;
6994
6995 if(get_qr(qr_NOCONTINUE))
6996 {
6997 if(standalone_mode)
6998 {
6999 ret=queding("End current game?",
7000 "The continue screen is disabled; the game",
7001 "will be reloaded from the last save.");
7002 }
7003 else
7004 {
7005 ret=queding("End current game?",
7006 "The continue screen is disabled. You will",
7007 "be returned to the file select screen.");
7008 }
7009 }
7010 else
7011 ret=queding("End current game?",NULL,NULL);
7012
7013 if(ret==1)
7014 {
7015 disableClickToFreeze=false;
7016 Quit=qQUIT;
7017
7018 // Trying to evade a door repair charge?
7019 if(repaircharge)
7020 {
7021 game->change_drupy(-repaircharge);
7022 repaircharge=0;
7023 }
7024
7025 return D_CLOSE;
7026 }
7027 }
7028
7029 return D_O_K;
7030 }
7031
7032 int32_t onTryQuitMenu()
7033 {
7034 return onTryQuit(true);
7035 }
7036
7037 int32_t onTryQuit(bool inMenu)
7038 {
7039 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7040 {
7041 if(active_cutscene.can_f6())
7042 {
7043 if(get_qr(qr_OLD_F6))
7044 {
7045 if(inMenu) onQuit();
7046 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
7047 }
7048 else
7049 {
7050 disableClickToFreeze=false;
7051 GameFlags |= GAMEFLAG_TRYQUIT;
7052 }
7053 return D_CLOSE;
7054 }
7055 else active_cutscene.error();
7056 }
7057
7058 return D_O_K;
7059 }
7060
7061 int32_t onReset()
7062 {
7063 if(queding(" Reset system? ",NULL,NULL)==1)
7064 {
7065 disableClickToFreeze=false;
7066 Quit=qRESET;
7067 replay_quit();
7068 return D_CLOSE;
7069 }
7070
7071 return D_O_K;
7072 }
7073
7074 int32_t onExit()
7075 {
7076 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7077 {
7078 Quit=qEXIT;
7079 return D_CLOSE;
7080 }
7081
7082 return D_O_K;
7083 }
7084
7085 int32_t onDebug()
7086 {
7087 if(debug_enabled)
7088 set_debug(!get_debug());
7089 return D_O_K;
7090 }
7091
7092 int32_t onHeartBeep()
7093 {
7094 heart_beep=!heart_beep;
7095 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7096 return D_O_K;
7097 }
7098
7099 int32_t onSaveIndicator()
7100 {
7101 use_save_indicator = use_save_indicator ? 0 : 1;
7102 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7103 return D_O_K;
7104 }
7105
7106 int32_t onEpilepsy()
7107 {
7108 if(jwin_alert3(
7109 "Epilepsy Flash Reduction",
7110 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7111 "Disabling this will restore standard flash and wavy behaviour.",
7112 "Proceed?",
7113 "&Yes",
7114 "&No",
7115 NULL,
7116 'y',
7117 'n',
7118 0,
7119 get_zc_font(font_lfont)) == 1)
7120 {
7121 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7122 zc_set_config("zeldadx","checked_epilepsy",1);
7123 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7124 }
7125 return D_O_K;
7126 }
7127
7128 bool rc = false;
7129
7130 static DIALOG getnum_dlg[] =
7131 {
7132 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7133 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7134 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7135 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7136 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7137 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7138 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7139 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7140 };
7141
7142 int32_t getnumber(const char *prompt,int32_t initialval)
7143 {
7144 char buf[20];
7145 sprintf(buf,"%d",initialval);
7146 getnum_dlg[0].dp=(void *)prompt;
7147 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7148 getnum_dlg[2].dp=buf;
7149
7150 large_dialog(getnum_dlg);
7151
7152 if(do_zqdialog(getnum_dlg,2)==3)
7153 return atoi(buf);
7154
7155 return initialval;
7156 }
7157
7158 int32_t onLife()
7159 {
7160 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7161 cheats_enqueue(Cheat::Life, value);
7162 return D_O_K;
7163 }
7164
7165 int32_t onHeartC()
7166 {
7167 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7168 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7169 cheats_enqueue(Cheat::MaxLife, max_life);
7170 cheats_enqueue(Cheat::Life, life);
7171 return D_O_K;
7172 }
7173
7174 int32_t onMagicC()
7175 {
7176 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7177 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,max_magic/game->get_mp_per_block())*game->get_mp_per_block();
7178 cheats_enqueue(Cheat::MaxMagic, max_magic);
7179 cheats_enqueue(Cheat::Magic, magic);
7180 return D_O_K;
7181 }
7182
7183 int32_t onRupies()
7184 {
7185 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7186 cheats_enqueue(Cheat::Rupies, value);
7187 return D_O_K;
7188 }
7189
7190 int32_t onMaxBombs()
7191 {
7192 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7193 cheats_enqueue(Cheat::MaxBombs, value);
7194 cheats_enqueue(Cheat::Bombs, value);
7195 return D_O_K;
7196 }
7197
7198 int32_t onRefillLife()
7199 {
7200 cheats_enqueue(Cheat::Life, game->get_maxlife());
7201 return D_O_K;
7202 }
7203 int32_t onRefillMagic()
7204 {
7205 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7206 return D_O_K;
7207 }
7208 int32_t onClock()
7209 {
7210 cheats_enqueue(Cheat::Clock);
7211 return D_O_K;
7212 }
7213
7214 int32_t onQstPath()
7215 {
7216 char path[2048];
7217
7218 chop_path(qstdir);
7219 strcpy(path,qstdir);
7220
7221 go();
7222
7223 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7224 {
7225 chop_path(path);
7226 fix_filename_case(path);
7227 fix_filename_slashes(path);
7228 strcpy(qstdir,path);
7229 strcpy(qstpath,qstdir);
7230 zc_set_config("zeldadx","quest_dir",qstdir);
7231 flush_config_file();
7232 }
7233
7234 comeback();
7235 return D_O_K;
7236 }
7237
7238 #include "dialog/cheat_dialog.h"
7239 int32_t onCheat()
7240 {
7241 call_setcheat_dialog();
7242 game->set_cheat(maxcheat);
7243 if(cheat) game->did_cheat(true);
7244 return D_O_K;
7245 }
7246
7247 int32_t onCheatRupies()
7248 {
7249 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7250 return D_O_K;
7251 }
7252
7253 int32_t onCheatArrows()
7254 {
7255 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7256 return D_O_K;
7257 }
7258
7259 int32_t onCheatBombs()
7260 {
7261 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7262 return D_O_K;
7263 }
7264
7265 // *** screen saver
7266
7267 9287211 int32_t after_time()
7268 {
7269
1/2
✓ Branch 0 taken 9287211 times.
✗ Branch 1 not taken.
9287211 if(ss_enable == 0)
7270 return INT_MAX;
7271
7272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
9287211 if(ss_after <= 0)
7273 return 5 * 60;
7274
7275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
9287211 if(ss_after <= 3)
7276 return ss_after * 15 * 60;
7277
7278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9287211 times.
9287211 if(ss_after <= 13)
7279 return (ss_after - 3) * 60 * 60;
7280
7281 9287211 return MAX_IDLE + 1;
7282 9287211 }
7283
7284 static const char *after_str[15] =
7285 {
7286 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7287 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7288 "Never"
7289 };
7290
7291 const char *after_list(int32_t index, int32_t *list_size)
7292 {
7293 if(index < 0)
7294 {
7295 *list_size = 15;
7296 return NULL;
7297 }
7298
7299 return after_str[index];
7300 }
7301
7302 117 static ListData after__list(after_list, &font);
7303
7304 static DIALOG scrsaver_dlg[] =
7305 {
7306 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7307 117 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7308 117 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7309 117 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7310 117 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7311 117 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7312 117 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7313 117 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7314 117 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7315 117 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7316 117 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7317 117 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7318 117 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7319 117 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7320 };
7321
7322 int32_t onScreenSaver()
7323 {
7324 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7325 int32_t oldcfgs[3];
7326 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7327 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7328 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7329
7330 large_dialog(scrsaver_dlg);
7331
7332 int32_t ret = do_zqdialog(scrsaver_dlg,-1);
7333
7334 if(ret == 8 || ret == 9)
7335 {
7336 ss_after = scrsaver_dlg[5].d1;
7337 ss_speed = scrsaver_dlg[6].d2;
7338 ss_density = scrsaver_dlg[7].d2;
7339 if(oldcfgs[0] != ss_after)
7340 zc_set_config(cfg_sect,"ss_after",ss_after);
7341 if(oldcfgs[1] != ss_speed)
7342 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7343 if(oldcfgs[2] != ss_density)
7344 zc_set_config(cfg_sect,"ss_density",ss_density);
7345 }
7346
7347 if(ret == 9)
7348 // preview Screen Saver
7349 {
7350 clear_keybuf();
7351 Matrix(ss_speed, ss_density, 30);
7352 system_pal(true);
7353 sys_mouse();
7354 }
7355
7356 return D_O_K;
7357 }
7358
7359 /***** Menus *****/
7360
7361 static MENU game_menu[] =
7362 {
7363 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7364 { (char *)"", NULL, NULL, 0, NULL },
7365 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7366 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7367 { (char *)"", NULL, NULL, 0, NULL },
7368 #ifdef __EMSCRIPTEN__
7369 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7370 #elif defined(ALLEGRO_MACOSX)
7371 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7372 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7373 #else
7374 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7375 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7376 #endif
7377 { NULL, NULL, NULL, 0, NULL }
7378 };
7379
7380 static MENU snapshot_format_menu[] =
7381 {
7382 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7383 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7384 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7385 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7386 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7387 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7388 { NULL, NULL, NULL, 0, NULL }
7389 };
7390
7391 static MENU controls_menu[] =
7392 {
7393 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7394 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7395 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7396 { NULL, NULL, NULL, 0, NULL }
7397 };
7398
7399 static MENU name_entry_mode_menu[] =
7400 {
7401 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7402 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7403 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7404 { NULL, NULL, NULL, 0, NULL }
7405 };
7406
7407 static void set_controls_menu_active()
7408 {
7409
7410 }
7411
7412 static MENU window_menu[] =
7413 {
7414 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7415 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7416 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7417 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7418 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7419 { NULL, NULL, NULL, 0, NULL }
7420 };
7421 static MENU options_menu[] =
7422 {
7423 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7424 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7425 { "&Window Settings", NULL, window_menu, 0, NULL },
7426 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7427 { "Pause In Background", onPauseInBackground, NULL, 0, NULL },
7428 { NULL, NULL, NULL, 0, NULL }
7429 };
7430 static MENU settings_menu[] =
7431 {
7432 { "&Sound...", onSound, NULL, 0, NULL },
7433 { "C&ontrols", NULL, controls_menu, 0, NULL },
7434 { "", NULL, NULL, 0, NULL },
7435 { "Options", NULL, options_menu, 0, NULL },
7436 { "", NULL, NULL, 0, NULL },
7437 //
7438 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7439 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7440 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7441 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7442 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7443 //
7444 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7445 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7446 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7447 { "", NULL, NULL, 0, NULL },
7448 { "Debu&g", onDebug, NULL, 0, NULL },
7449 //
7450 { NULL, NULL, NULL, 0, NULL }
7451 };
7452
7453
7454 static MENU misc_menu[] =
7455 {
7456 { (char *)"&About...", onAbout, NULL, 0, NULL },
7457 // TODO: re-enable, but: 1) do not use a bitmap thing that is hard to update 2) update names and 3) don't use the Z-word.
7458 { (char *)"&Credits...", onCredits, NULL, D_DISABLED, NULL },
7459 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7460 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7461 { (char *)"", NULL, NULL, 0, NULL },
7462 //5
7463 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7464 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7465 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7466 { (char *)"", NULL, NULL, 0, NULL },
7467 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7468 //10
7469 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7470 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7471 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7472 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7473 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7474 //15
7475 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7476 { NULL, NULL, NULL, 0, NULL }
7477 };
7478
7479 static MENU refill_menu[] =
7480 {
7481 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7482 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7483 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7484 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7485 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7486 { NULL, NULL, NULL, 0, NULL }
7487 };
7488
7489 static MENU show_menu[] =
7490 {
7491 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7492 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7493 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7494 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7495 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7496 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7497 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7498 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7499 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7500 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7501 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7502 { (char *)"", NULL, NULL, 0, NULL },
7503 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7504 { (char *)"", NULL, NULL, 0, NULL },
7505 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7506 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7507 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7508 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7509 { NULL, NULL, NULL, 0, NULL }
7510 };
7511
7512 static MENU cheat_menu[] =
7513 {
7514 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7515 { (char *)"", NULL, NULL, 0, NULL },
7516 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7517 { (char *)"", NULL, NULL, 0, NULL },
7518 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7519 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7520 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7521 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7522 { (char *)"", NULL, NULL, 0, NULL },
7523 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7524 { (char *)"", NULL, NULL, 0, NULL },
7525 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7526 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7527 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7528 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7529 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7530 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7531 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7532 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7533 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7534 { NULL, NULL, NULL, 0, NULL }
7535 };
7536
7537 #if DEVLEVEL > 0
7538 int32_t devLogging();
7539 int32_t devDebug();
7540 int32_t devTimestmp();
7541 #if DEVLEVEL > 1
7542 int32_t setCheat();
7543 #endif //DEVLEVEL > 1
7544 enum
7545 {
7546 dv_log,
7547 // dv_dbg,
7548 dv_tmpstmp,
7549 #if DEVLEVEL > 1
7550 dv_nil,
7551 dv_setcheat,
7552 #endif //DEVLEVEL > 1
7553 dv_max
7554 };
7555 static MENU dev_menu[] =
7556 {
7557 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7558 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7559 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7560 #if DEVLEVEL > 1
7561 { (char *)"", NULL, NULL, 0, NULL },
7562 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7563 #endif //DEVLEVEL > 1
7564 { NULL, NULL, NULL, 0, NULL }
7565 };
7566 int32_t devLogging()
7567 {
7568 dev_logging = !dev_logging;
7569 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7570 return D_O_K;
7571 }
7572 // int32_t devDebug()
7573 // {
7574 // dev_debug = !dev_debug;
7575 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7576 // return D_O_K;
7577 // }
7578 int32_t devTimestmp()
7579 {
7580 dev_timestmp = !dev_timestmp;
7581 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7582 return D_O_K;
7583 }
7584 #if DEVLEVEL > 1
7585 int32_t setCheat()
7586 {
7587 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7588 return D_O_K;
7589 }
7590 #endif //DEVLEVEL > 1
7591 #endif //DEVLEVEL > 0
7592
7593 MENU the_player_menu[] =
7594 {
7595 { (char *)"&Game", NULL, game_menu, 0, NULL },
7596 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7597 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7598 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7599 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7600 #if DEVLEVEL > 0
7601 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7602 #endif
7603 { NULL, NULL, NULL, 0, NULL }
7604 };
7605 int32_t onPauseInBackground()
7606 {
7607 if(jwin_alert3(
7608 "Toggle Pause In Background",
7609 "This action will change whether ZC Player pauses when the window loses focus.",
7610 "",
7611 "Proceed?",
7612 "&Yes",
7613 "&No",
7614 NULL,
7615 'y',
7616 'n',
7617 0,
7618 get_zc_font(font_lfont)) == 1)
7619 {
7620 pause_in_background = pause_in_background ? 0 : 1;
7621 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7622 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7623 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7624 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7625 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7626 }
7627 options_menu[4].flags =(pause_in_background)?D_SELECTED:0;
7628 return D_O_K;
7629 }
7630
7631 int32_t onKeyboardEntry()
7632 {
7633 NameEntryMode=0;
7634 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7635 return D_O_K;
7636 }
7637
7638 int32_t onLetterGridEntry()
7639 {
7640 NameEntryMode=1;
7641 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7642 return D_O_K;
7643 }
7644
7645 int32_t onExtLetterGridEntry()
7646 {
7647 NameEntryMode=2;
7648 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7649 return D_O_K;
7650 }
7651
7652 static BITMAP* oldscreen;
7653 int32_t onFullscreenMenu()
7654 {
7655 // super hacks
7656 screen = oldscreen;
7657 if (onFullscreen() == D_REDRAW)
7658 {
7659 oldscreen = screen;
7660 }
7661 screen = menu_bmp;
7662 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7663 return D_O_K;
7664 }
7665
7666 117 void fix_menu()
7667 {
7668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if(!debug_enabled)
7669 117 settings_menu[13].text = NULL;
7670 117 }
7671
7672 static DIALOG system_dlg[] =
7673 {
7674 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7675 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7676 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7677 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7678 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7679 #ifndef ALLEGRO_MACOSX
7680 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7681 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7682 #else
7683 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7684 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7685 #endif
7686 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7687 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7688 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7689 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7690 };
7691
7692 void reset_snapshot_format_menu()
7693 {
7694 for(int32_t i=0; i<ssfmtMAX; ++i)
7695 {
7696 snapshot_format_menu[i].flags=0;
7697 }
7698 }
7699
7700 int32_t onSetSnapshotFormat()
7701 {
7702 switch(active_menu->text[1])
7703 {
7704 case 'B': //"&BMP"
7705 SnapshotFormat=0;
7706 break;
7707
7708 case 'G': //"&GIF"
7709 SnapshotFormat=1;
7710 break;
7711
7712 case 'J': //"&JPG"
7713 SnapshotFormat=2;
7714 break;
7715
7716 case 'P': //"&PNG"
7717 SnapshotFormat=3;
7718 break;
7719
7720 case 'C': //"PC&X"
7721 SnapshotFormat=4;
7722 break;
7723
7724 case 'T': //"&TGA"
7725 SnapshotFormat=5;
7726 break;
7727
7728 case 'L': //"&LBM"
7729 SnapshotFormat=6;
7730 break;
7731 }
7732 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7733
7734 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7735 return D_O_K;
7736 }
7737
7738
7739 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7740 {
7741 PALETTE tmp;
7742
7743 for(int32_t i=0; i<256; i++)
7744 {
7745 tmp[i].r=r;
7746 tmp[i].g=g;
7747 tmp[i].b=b;
7748 }
7749
7750 fade_interpolate(src,tmp,dest,pos,from,to);
7751 }
7752
7753 14 void system_pal(bool force)
7754 {
7755
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 if(is_sys_pal && !force) return;
7756 14 is_sys_pal = true;
7757 14 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7758 14 hw_palette = &syspal;
7759 14 update_hw_pal = true;
7760 14 }
7761
7762 static uint32_t entered_sys_pal = 0;
7763 14 void enter_sys_pal()
7764 {
7765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
7766 {
7767 if(entered_sys_pal)
7768 ++entered_sys_pal;
7769 return;
7770 }
7771 14 sys_mouse();
7772 14 system_pal(true);
7773 14 ++entered_sys_pal;
7774 14 }
7775 14 void exit_sys_pal()
7776 {
7777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
7778 {
7779
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
7780 {
7781 14 game_pal();
7782 14 game_mouse();
7783 14 }
7784 14 }
7785 14 }
7786
7787 void switch_out_callback()
7788 {
7789 if (pause_in_background && !MenuOpen)
7790 {
7791 System();
7792 }
7793 }
7794
7795 void switch_in_callback()
7796 {
7797 }
7798
7799 424 void game_pal()
7800 {
7801 424 is_sys_pal = false;
7802 424 entered_sys_pal = 0;
7803 424 hw_palette = &RAMpal;
7804 424 update_hw_pal = true;
7805 424 }
7806
7807 static char bar_str[] = "";
7808
7809 14 void music_pause()
7810 {
7811 //al_pause_duh(tmplayer);
7812 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
7813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(zcmixer->oldtrack)
7814 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7815 14 zc_midi_pause();
7816 14 }
7817
7818 void music_resume()
7819 {
7820 //al_resume_duh(tmplayer);
7821 zcmusic_pause(zcmusic, ZCM_RESUME);
7822 if (zcmixer->oldtrack)
7823 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7824 zc_midi_resume();
7825 }
7826
7827 3361 void music_stop()
7828 {
7829 //al_stop_duh(tmplayer);
7830 //unload_duh(tmusic);
7831 //tmusic=NULL;
7832 //tmplayer=NULL;
7833 3361 zcmusic_stop(zcmusic);
7834 3361 zcmusic_unload_file(zcmusic);
7835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3361 times.
3361 if (zcmixer->oldtrack)
7836 {
7837 zcmusic_stop(zcmixer->oldtrack);
7838 zcmusic_unload_file(zcmixer->oldtrack);
7839 }
7840 3361 zcmixer->newtrack = NULL;
7841 3361 zc_stop_midi();
7842 3361 currmidi=-1;
7843 3361 }
7844
7845 void System()
7846 {
7847 mouse_down=gui_mouse_b();
7848 music_pause();
7849 pause_all_sfx();
7850 MenuOpen = true;
7851 enter_sys_pal();
7852 // FONT *oldfont=font;
7853 // font=tfont;
7854
7855 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7856 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7857
7858 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7859 #if DEVLEVEL > 1
7860 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7861 #endif
7862 game_menu[3].flags =
7863 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7864 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7865 clear_keybuf();
7866
7867 DIALOG_PLAYER *p;
7868
7869 clear_bitmap(menu_bmp);
7870 oldscreen = screen;
7871 screen = menu_bmp;
7872
7873 p = init_dialog(system_dlg,-1);
7874
7875 // drop the menu on startup if menu button pressed
7876 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7877 simulate_keypress(KEY_G << 8);
7878
7879 do
7880 {
7881 if(handle_close_btn_quit())
7882 break;
7883
7884 rest(17);
7885
7886 if(mouse_down && !gui_mouse_b())
7887 mouse_down=0;
7888
7889 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7890 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7891 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7892 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7893 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7894 settings_menu[10].flags = NESquit?D_SELECTED:0;
7895 settings_menu[11].flags = volkeys?D_SELECTED:0;
7896
7897 window_menu[0].flags = DragAspect?D_SELECTED:0;
7898 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7899 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7900 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7901 window_menu[4].flags = stretchGame?D_SELECTED:0;
7902
7903 options_menu[3].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7904 options_menu[4].flags = (pause_in_background)?D_SELECTED:0;
7905
7906 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7907 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7908 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7909
7910 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7911 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7912 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7913
7914 bool nocheat = (replay_is_replaying() || !Playing
7915 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7916 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7917 cheat_menu[0].flags = 0;
7918 refill_menu[4].flags = get_qr(qr_TRUEARROWS) ? 0 : D_DISABLED;
7919 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7920 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7921 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7922 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7923 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
7924 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
7925 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
7926 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
7927
7928 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
7929 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
7930 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
7931 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
7932 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
7933 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
7934 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
7935 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
7936 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
7937 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
7938 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
7939 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
7940 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
7941 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
7942 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
7943
7944 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
7945 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
7946
7947 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
7948 (char *)"Disable recording new saves" :
7949 (char *)"Enable recording new saves";
7950 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
7951 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
7952 (char *)"Stop recording" :
7953 (char *)"Stop replaying";
7954 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
7955 replay_menu[6].text = replay_is_snapshot_all_frames() ?
7956 (char *)"Disable snapshot all frames" :
7957 (char *)"Enable snapshot all frames";
7958
7959 reset_snapshot_format_menu();
7960 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
7961
7962 if(debug_enabled)
7963 {
7964 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
7965 }
7966
7967 if(gui_mouse_b() && !mouse_down)
7968 break;
7969
7970 // press menu to drop the menu
7971 if(rMbtn())
7972 simulate_keypress(KEY_G << 8);
7973
7974 if(input_idle(true) > after_time())
7975 // run Screeen Saver
7976 {
7977 // Screen saver enabled for now.
7978 clear_keybuf();
7979 Matrix(ss_speed, ss_density, 0);
7980 system_pal(true);
7981 sys_mouse();
7982 broadcast_dialog_message(MSG_DRAW, 0);
7983 }
7984
7985 update_hw_screen();
7986 }
7987 while(update_dialog(p));
7988
7989 screen = oldscreen;
7990
7991 // font=oldfont;
7992 mouse_down=gui_mouse_b();
7993 shutdown_dialog(p);
7994 MenuOpen = false;
7995 if(Quit)
7996 {
7997 kill_sfx();
7998 music_stop();
7999 update_hw_screen();
8000 }
8001 else
8002 {
8003 music_resume();
8004 resume_all_sfx();
8005
8006 if(rc)
8007 ringcolor(false);
8008 }
8009 exit_sys_pal();
8010
8011 eat_buttons();
8012
8013 rc=false;
8014 clear_keybuf();
8015
8016 zc_init_apply_cheat_delta();
8017 }
8018
8019 117 void fix_dialogs()
8020 {
8021 117 jwin_center_dialog(about_dlg);
8022 117 jwin_center_dialog(gamepad_dlg);
8023 117 jwin_center_dialog(credits_dlg);
8024 117 jwin_center_dialog(gamemode_dlg);
8025 117 jwin_center_dialog(getnum_dlg);
8026 117 jwin_center_dialog(goto_dlg);
8027 117 jwin_center_dialog(keyboard_control_dlg);
8028 117 jwin_center_dialog(midi_dlg);
8029 117 jwin_center_dialog(quest_dlg);
8030 117 jwin_center_dialog(scrsaver_dlg);
8031 117 jwin_center_dialog(sound_dlg);
8032 117 jwin_center_dialog(triforce_dlg);
8033
8034 // digi_dp[1] += scrx;
8035 // digi_dp[2] += scry;
8036 // midi_dp[1] += scrx;
8037 // midi_dp[2] += scry;
8038 // pan_dp[1] += scrx;
8039 // pan_dp[2] += scry;
8040 // emus_dp[1] += scrx;
8041 // emus_dp[2] += scry;
8042 // buf_dp[1] += scrx;
8043 // buf_dp[2] += scry;
8044 // sfx_dp[1] += scrx;
8045 // sfx_dp[2] += scry;
8046 117 }
8047
8048 /*****************************/
8049 /**** Custom Sound System ****/
8050 /*****************************/
8051
8052 117 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8053 {
8054
2/4
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
117 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8055 }
8056
8057 149 int32_t get_emusic_volume()
8058 {
8059 149 int32_t temp_volume = emusic_volume;
8060
2/4
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
149 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8061 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if (!zcmusic)
8063 149 return temp_volume;
8064 return (temp_volume * zcmusic->fadevolume) / 10000;
8065 149 }
8066
8067 int32_t get_zcmusicpos()
8068 {
8069 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8070 return debugtracething;
8071 return 0;
8072 }
8073
8074 void set_zcmusicpos(int32_t position)
8075 {
8076 zcmusic_set_curpos(zcmusic, position);
8077 }
8078
8079 void set_zcmusicspeed(int32_t speed)
8080 {
8081 zcmusic_set_speed(zcmusic, speed);
8082 }
8083
8084 int32_t get_zcmusiclen()
8085 {
8086 return zcmusic_get_length(zcmusic);
8087 }
8088
8089 void set_zcmusicloop(double start, double end)
8090 {
8091 zcmusic_set_loop(zcmusic, start, end);
8092 }
8093
8094 63941 void jukebox(int32_t index,int32_t loop)
8095 {
8096
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if (is_headless())
8097 63941 return;
8098
8099 music_stop();
8100
8101 if(index<0) index=MAXMIDIS-1;
8102
8103 if(index>=MAXMIDIS) index=0;
8104
8105 music_stop();
8106
8107 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8108 // stuck notes when a song stops. This fixes it.
8109 if(strcmp(midi_driver->name, "DIGMID")==0)
8110 zc_set_volume(0, 0);
8111
8112 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8113 zc_play_midi((MIDI*)tunes[index].data,loop);
8114
8115 if(tunes[index].start>0)
8116 zc_midi_seek(tunes[index].start);
8117
8118 midi_loop_start = tunes[index].loop_start;
8119 midi_loop_end = tunes[index].loop_end;
8120
8121 currmidi=index;
8122 master_volume(digi_volume, midi_volume);
8123 //midi_paused=false;
8124 63941 }
8125
8126 63941 void jukebox(int32_t index)
8127 {
8128
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index<0) index=MAXMIDIS-1;
8129
8130
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index>=MAXMIDIS) index=0;
8131
8132 // do nothing if it's already playing
8133
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63941 if(index==currmidi && midi_pos>=0)
8134 {
8135 return;
8136 }
8137
8138 63941 jukebox(index,tunes[index].loop);
8139 63941 }
8140
8141 16 void play_DmapMusic()
8142 {
8143
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (is_headless())
8144 16 return;
8145
8146 static char tfile[2048];
8147 static int32_t ttrack=0;
8148 bool domidi=false;
8149
8150 int32_t fadeoutframes = 0;
8151 if (zcmusic != NULL)
8152 fadeoutframes = zcmusic->fadeoutframes;
8153
8154 if(DMaps[currdmap].tmusic[0]!=0)
8155 {
8156 if(zcmusic==NULL ||
8157 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8158 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8159 {
8160 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8161 {
8162 if (play_enh_music_crossfade(DMaps[currdmap].tmusic, qstpath, DMaps[currdmap].tmusictrack, get_emusic_volume(), DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8163 {
8164 if (zcmusic != NULL)
8165 {
8166 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8167 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8168 }
8169 }
8170 }
8171 else
8172 {
8173 if (zcmusic != NULL)
8174 {
8175 zcmusic_stop(zcmusic);
8176 zcmusic_unload_file(zcmusic);
8177 zcmusic = NULL;
8178 zcmixer->newtrack = NULL;
8179 }
8180
8181 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8182 zcmixer->newtrack = zcmusic;
8183
8184 if (zcmusic != NULL)
8185 {
8186 zc_stop_midi();
8187 strcpy(tfile, DMaps[currdmap].tmusic);
8188 zcmusic_play(zcmusic, emusic_volume);
8189 int32_t temptracks = 0;
8190 temptracks = zcmusic_get_tracks(zcmusic);
8191 temptracks = (temptracks < 2) ? 1 : temptracks;
8192 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8193 zcmusic_change_track(zcmusic, ttrack);
8194 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8195 }
8196 else
8197 {
8198 tfile[0] = 0;
8199 domidi = true;
8200 }
8201 }
8202 }
8203 }
8204 else
8205 {
8206 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8207 {
8208 play_enh_music_crossfade(NULL, qstpath, DMaps[currdmap].tmusictrack, get_emusic_volume(), DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8209 }
8210 else
8211 {
8212 domidi = true;
8213 }
8214 }
8215
8216 if(domidi)
8217 {
8218 int32_t m=DMaps[currdmap].midi;
8219
8220 switch(m)
8221 {
8222 case 1:
8223 jukebox(ZC_MIDI_OVERWORLD);
8224 break;
8225
8226 case 2:
8227 jukebox(ZC_MIDI_DUNGEON);
8228 break;
8229
8230 case 3:
8231 jukebox(ZC_MIDI_LEVEL9);
8232 break;
8233
8234 default:
8235 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8236 jukebox(m+MIDIOFFSET_DMAP);
8237 else
8238 music_stop();
8239 }
8240 }
8241 16 }
8242
8243 15755 void playLevelMusic()
8244 {
8245
1/2
✓ Branch 0 taken 15755 times.
✗ Branch 1 not taken.
15755 if (is_headless())
8246 15755 return;
8247
8248 int32_t m=tmpscr->screen_midi;
8249
8250 switch(m)
8251 {
8252 case -2:
8253 music_stop();
8254 break;
8255
8256 case -1:
8257 play_DmapMusic();
8258 break;
8259
8260 case 1:
8261 jukebox(ZC_MIDI_OVERWORLD);
8262 break;
8263
8264 case 2:
8265 jukebox(ZC_MIDI_DUNGEON);
8266 break;
8267
8268 case 3:
8269 jukebox(ZC_MIDI_LEVEL9);
8270 break;
8271
8272 default:
8273 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8274 jukebox(m+MIDIOFFSET_MAPSCR);
8275 else
8276 music_stop();
8277 }
8278 15755 }
8279
8280 117 void master_volume(int32_t dv,int32_t mv)
8281 {
8282
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 117 times.
✗ Branch 7 not taken.
117 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8283
8284
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 117 times.
✗ Branch 7 not taken.
117 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8285
8286
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 117 times.
117 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8287 117 int32_t temp_vol = midi_volume;
8288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8289 117 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8290 117 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8291 117 }
8292
8293 /*****************/
8294 /***** SFX *****/
8295 /*****************/
8296
8297 // array of voices, one for each sfx sample in the data file
8298 // 0+ = voice #
8299 // -1 = voice not allocated
8300 117 void Z_init_sound()
8301 {
8302
2/2
✓ Branch 0 taken 29952 times.
✓ Branch 1 taken 117 times.
30069 for(int32_t i=0; i<WAV_COUNT; i++)
8303 29952 sfx_voice[i]=-1;
8304
8305 117 const char* midis[ZC_MIDI_COUNT] = {
8306 "assets/dungeon.mid",
8307 "assets/ending.mid",
8308 "assets/gameover.mid",
8309 "assets/level9.mid",
8310 "assets/overworld.mid",
8311 "assets/title.mid",
8312 "assets/triforce.mid",
8313 };
8314
2/2
✓ Branch 0 taken 819 times.
✓ Branch 1 taken 117 times.
936 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8315 {
8316 819 tunes[i].data = load_midi(midis[i]);
8317
1/2
✓ Branch 0 taken 819 times.
✗ Branch 1 not taken.
819 if (!tunes[i].data)
8318 Z_error_fatal("Missing required file %s\n", midis[i]);
8319 819 }
8320
8321
2/2
✓ Branch 0 taken 29484 times.
✓ Branch 1 taken 117 times.
29601 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8322 29484 tunes[ZC_MIDI_COUNT+j].data=NULL;
8323
8324 117 master_volume(digi_volume,midi_volume);
8325 117 }
8326
8327 // returns number of voices currently allocated
8328 int32_t sfx_count()
8329 {
8330 int32_t c=0;
8331
8332 for(int32_t i=0; i<WAV_COUNT; i++)
8333 if(sfx_voice[i]!=-1)
8334 ++c;
8335
8336 return c;
8337 }
8338
8339 // clean up finished samples
8340 9218467 void sfx_cleanup()
8341 {
8342
2/2
✓ Branch 0 taken 2359927552 times.
✓ Branch 1 taken 9218467 times.
2369146019 for(int32_t i=0; i<WAV_COUNT; i++)
8343
3/4
✓ Branch 0 taken 619766 times.
✓ Branch 1 taken 2359307786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619766 times.
2360547318 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8344 {
8345 619766 deallocate_voice(sfx_voice[i]);
8346 619766 sfx_voice[i]=-1;
8347 619766 }
8348 9218467 }
8349
8350 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8351 // if a voice is already allocated (and/or playing), then it just returns true
8352 // Returns true: voice is allocated
8353 // false: unsuccessful
8354 964184 bool sfx_init(int32_t index)
8355 {
8356 // check index
8357
3/4
✓ Branch 0 taken 721795 times.
✓ Branch 1 taken 242389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721795 times.
964184 if(index<=0 || index>=WAV_COUNT)
8358 242389 return false;
8359
8360
2/2
✓ Branch 0 taken 102011 times.
✓ Branch 1 taken 619784 times.
721795 if(sfx_voice[index]==-1)
8361 {
8362
2/2
✓ Branch 0 taken 209876 times.
✓ Branch 1 taken 409908 times.
619784 if(sfxdat)
8363 {
8364
1/2
✓ Branch 0 taken 209876 times.
✗ Branch 1 not taken.
209876 if(index<Z35)
8365 {
8366 209876 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8367 209876 }
8368 else
8369 {
8370 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8371 }
8372 209876 }
8373 else
8374 {
8375 409908 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8376 }
8377
8378 619784 int32_t temp_volume = sfx_volume;
8379
2/4
✓ Branch 0 taken 619784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 619784 times.
✗ Branch 3 not taken.
619784 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8380 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8381 619784 voice_set_volume(sfx_voice[index], temp_volume);
8382 619784 }
8383
8384 721795 return sfx_voice[index] != -1;
8385 964184 }
8386
8387 int32_t sfx_get_default_freq(int32_t index)
8388 {
8389 if (sfxdat)
8390 {
8391 if (index < Z35)
8392 {
8393 return ((SAMPLE*)sfxdata[index].dat)->freq;
8394 }
8395 else
8396 {
8397 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8398 }
8399 }
8400 else
8401 {
8402 return customsfxdata[index].freq;
8403 }
8404 }
8405
8406 int32_t sfx_get_length(int32_t index)
8407 {
8408 if (sfxdat)
8409 {
8410 if (index < Z35)
8411 {
8412 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8413 }
8414 else
8415 {
8416 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8417 }
8418 }
8419 else
8420 {
8421 return int32_t(customsfxdata[index].len);
8422 }
8423 }
8424
8425 // plays an sfx sample
8426 964184 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8427 {
8428
2/2
✓ Branch 0 taken 721795 times.
✓ Branch 1 taken 242389 times.
964184 if(!sfx_init(index))
8429 242389 return;
8430
1/2
✓ Branch 0 taken 721795 times.
✗ Branch 1 not taken.
721795 if (!is_headless())
8431 {
8432 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8433 voice_set_pan(sfx_voice[index], pan);
8434
8435 // Only used by ZScript currently
8436 if (freq <= -1)
8437 {
8438 freq = sfx_get_default_freq(index);
8439 }
8440 voice_set_frequency(sfx_voice[index], freq);
8441
8442 // Only used by ZScript currently
8443 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8444 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8445 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8446 voice_set_volume(sfx_voice[index], temp_volume);
8447
8448 int32_t pos = voice_get_position(sfx_voice[index]);
8449
8450 if (restart) voice_set_position(sfx_voice[index], 0);
8451
8452 if (pos <= 0)
8453 voice_start(sfx_voice[index]);
8454 }
8455
8456
3/4
✓ Branch 0 taken 398004 times.
✓ Branch 1 taken 323791 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398004 times.
721795 if (restart && replay_is_debug())
8457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398004 times.
398004 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8458 964184 }
8459
8460 // true if sfx is allocated
8461 68052 bool sfx_allocated(int32_t index)
8462 {
8463
3/4
✓ Branch 0 taken 9923 times.
✓ Branch 1 taken 58129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9923 times.
68052 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8464 }
8465
8466 // start it (in loop mode) if it's not already playing,
8467 // otherwise adjust it to play in loop mode -DD
8468 55174 void cont_sfx(int32_t index)
8469 {
8470
1/2
✓ Branch 0 taken 55174 times.
✗ Branch 1 not taken.
55174 if (is_headless())
8471 55174 return;
8472
8473 if(!sfx_init(index))
8474 {
8475 return;
8476 }
8477
8478 if(voice_get_position(sfx_voice[index])<=0)
8479 {
8480 voice_set_position(sfx_voice[index],0);
8481 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8482 voice_start(sfx_voice[index]);
8483 }
8484 else
8485 {
8486 adjust_sfx(index, 128, true);
8487 }
8488 55174 }
8489
8490 // adjust parameters while playing
8491 4075 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8492 {
8493
4/6
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2315 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2315 times.
4075 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8494 4075 return;
8495
8496 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8497 voice_set_pan(sfx_voice[index],pan);
8498 4075 }
8499
8500 // pauses a voice
8501 1725 void pause_sfx(int32_t index)
8502 {
8503
3/6
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1725 times.
1725 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8504 voice_stop(sfx_voice[index]);
8505 1725 }
8506
8507 // resumes a voice
8508 747 void resume_sfx(int32_t index)
8509 {
8510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 if (is_headless())
8511 747 return;
8512
8513 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8514 voice_start(sfx_voice[index]);
8515 747 }
8516
8517 // pauses all active voices
8518 452 void pause_all_sfx()
8519 {
8520
2/2
✓ Branch 0 taken 115712 times.
✓ Branch 1 taken 452 times.
116164 for(int32_t i=0; i<WAV_COUNT; i++)
8521
2/2
✓ Branch 0 taken 115711 times.
✓ Branch 1 taken 1 times.
115713 if(sfx_voice[i]!=-1)
8522 1 voice_stop(sfx_voice[i]);
8523 452 }
8524
8525 // resumes all paused voices
8526 438 void resume_all_sfx()
8527 {
8528
2/2
✓ Branch 0 taken 112128 times.
✓ Branch 1 taken 438 times.
112566 for(int32_t i=0; i<WAV_COUNT; i++)
8529
1/2
✓ Branch 0 taken 112128 times.
✗ Branch 1 not taken.
112128 if(sfx_voice[i]!=-1)
8530 voice_start(sfx_voice[i]);
8531 438 }
8532
8533 // stops an sfx and deallocates the voice
8534 7462663 void stop_sfx(int32_t index)
8535 {
8536
3/4
✓ Branch 0 taken 6277597 times.
✓ Branch 1 taken 1185066 times.
✓ Branch 2 taken 6277597 times.
✗ Branch 3 not taken.
7462663 if(index<=0 || index>=WAV_COUNT)
8537 1185066 return;
8538
8539
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6277585 times.
6277597 if(sfx_voice[index]!=-1)
8540 {
8541 12 deallocate_voice(sfx_voice[index]);
8542 12 sfx_voice[index]=-1;
8543 12 }
8544 7462663 }
8545
8546 // Stops SFX played by Hero's item of the given family
8547 128638 void stop_item_sfx(int32_t family)
8548 {
8549 128638 int32_t id=current_item_id(family);
8550
8551
2/2
✓ Branch 0 taken 128083 times.
✓ Branch 1 taken 555 times.
128638 if(id<0)
8552 128083 return;
8553
8554 555 stop_sfx(itemsbuf[id].usesound);
8555 128638 }
8556
8557 3223 void kill_sfx()
8558 {
8559
2/2
✓ Branch 0 taken 825088 times.
✓ Branch 1 taken 3223 times.
828311 for(int32_t i=0; i<WAV_COUNT; i++)
8560
2/2
✓ Branch 0 taken 825082 times.
✓ Branch 1 taken 6 times.
825094 if(sfx_voice[i]!=-1)
8561 {
8562 6 deallocate_voice(sfx_voice[i]);
8563 6 sfx_voice[i]=-1;
8564 6 }
8565 3223 }
8566
8567 659811 int32_t pan(int32_t x)
8568 {
8569
1/4
✓ Branch 0 taken 659811 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659811 switch(pan_style)
8570 {
8571 case 0:
8572 return 128;
8573
8574 case 1:
8575 659811 return vbound((x>>1)+68,0,255);
8576
8577 case 2:
8578 return vbound(((x*3)>>2)+36,0,255);
8579 }
8580
8581 return vbound(x,0,255);
8582 659811 }
8583
8584 /*******************************/
8585 /******* Input Handlers ********/
8586 /*******************************/
8587
8588 25094006 bool joybtn(int32_t b)
8589 {
8590
1/2
✓ Branch 0 taken 25094006 times.
✗ Branch 1 not taken.
25094006 if(b == 0)
8591 return false;
8592
1/2
✓ Branch 0 taken 25094006 times.
✗ Branch 1 not taken.
25094006 if (b-1 >= joy[joystick_index].num_buttons)
8593 25094006 return false;
8594
8595 return joy[joystick_index].button[b-1].b !=0;
8596 25094006 }
8597
8598 bool joystick(int32_t s)
8599 {
8600 if(s < 0)
8601 return false;
8602 if (s >= joy[joystick_index].num_sticks)
8603 return false;
8604
8605 for (int i = 0; i < joy[joystick_index].stick[s].num_axis; i++)
8606 {
8607 if (joy[joystick_index].stick[s].axis[i].d1 || joy[joystick_index].stick[s].axis[i].d2)
8608 return true;
8609 }
8610 return false;
8611 }
8612
8613 const char* joybtn_name(int32_t b)
8614 {
8615 if (b <= 0 || b > joy[joystick_index].num_buttons)
8616 return "";
8617
8618 return joy[joystick_index].button[b-1].name;
8619 }
8620
8621 const char* joystick_name(int32_t s)
8622 {
8623 if (s < 0 || s >= joy[joystick_index].num_sticks)
8624 return "";
8625
8626 return joy[joystick_index].stick[s].name;
8627 }
8628
8629 int32_t next_press_key();
8630
8631 int32_t next_joy_input(bool buttons)
8632 {
8633 clear_keybuf();
8634
8635 //first, we need to wait until they're pressing no buttons
8636 for(;;)
8637 {
8638 if(keypressed())
8639 {
8640 switch(readkey()>>8)
8641 {
8642 case KEY_ESC:
8643 return -1;
8644
8645 case KEY_SPACE:
8646 return 0;
8647 }
8648 }
8649
8650 poll_joystick();
8651 bool done = true;
8652
8653 if (buttons)
8654 {
8655 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8656 {
8657 if(joybtn(i)) done = false;
8658 }
8659 }
8660 else
8661 {
8662 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8663 {
8664 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8665 return -2;
8666 }
8667 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8668 {
8669 if(joystick(i)) done = false;
8670 }
8671 }
8672
8673 if(done) break;
8674 rest(1);
8675 }
8676
8677 //now, we need to wait for them to press any button
8678 for(;;)
8679 {
8680 if(keypressed())
8681 {
8682 switch(readkey()>>8)
8683 {
8684 case KEY_ESC:
8685 return -1;
8686
8687 case KEY_SPACE:
8688 return 0;
8689 }
8690 }
8691
8692 poll_joystick();
8693
8694 if (buttons)
8695 {
8696 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8697 {
8698 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8699 return -2;
8700 }
8701 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8702 {
8703 if(joybtn(i))
8704 return i;
8705 }
8706 }
8707 else
8708 {
8709 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8710 {
8711 if(joystick(i))
8712 return i;
8713 }
8714 }
8715 rest(1);
8716 }
8717 }
8718
8719 1209106 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8720 {
8721
2/2
✓ Branch 0 taken 1204755 times.
✓ Branch 1 taken 4351 times.
1209106 bool ret = btn && !flag;
8722 1209106 flag = rawbtn;
8723
8724 1209106 return ret;
8725 }
8726 190805710 static bool rButton(bool &btn, bool &flag)
8727 {
8728
2/2
✓ Branch 0 taken 183961269 times.
✓ Branch 1 taken 6844441 times.
190805710 bool ret = btn && !flag;
8729 190805710 flag = btn;
8730
8731 190805710 return ret;
8732 }
8733 2888985 static bool rButtonPeek(bool btn, bool flag)
8734 {
8735
2/2
✓ Branch 0 taken 2685887 times.
✓ Branch 1 taken 203098 times.
2888985 if(!btn)
8736 {
8737 2685887 return false;
8738 }
8739
2/2
✓ Branch 0 taken 17939 times.
✓ Branch 1 taken 185159 times.
203098 else if(!flag)
8740 {
8741 17939 return true;
8742 }
8743
8744 185159 return false;
8745 2888985 }
8746
8747 // Updated only by keyboard/gamepad.
8748 // If in replay mode, this is set directly by the replay system.
8749 // This should never be read from directly - use control_state instead.
8750 bool raw_control_state[ZC_CONTROL_STATES];
8751
8752 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8753 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8754 // lasts until the next call to load_control_state.
8755 bool control_state[ZC_CONTROL_STATES];
8756 bool disable_control[ZC_CONTROL_STATES];
8757 bool drunk_toggle_state[11];
8758 bool disabledKeys[127];
8759 bool KeyInput[127];
8760 bool KeyPress[127];
8761
8762 bool key_current_frame[127];
8763 bool key_previous_frame[127];
8764
8765 static bool key_system[127];
8766 static bool key_system_previous[127];
8767 static bool key_system_press[127];
8768
8769 bool button_press[ZC_CONTROL_STATES];
8770 bool button_hold[ZC_CONTROL_STATES];
8771
8772 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8773 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8774 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8775 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8776 #define STICK_PRECISION 56 //define your own sensitivity
8777
8778 7801176 void load_control_state()
8779 {
8780 7801176 load_control_called_this_frame = true;
8781
8782
2/2
✓ Branch 0 taken 4833663 times.
✓ Branch 1 taken 2967513 times.
7801176 if (replay_version_check(8, 11))
8783 {
8784
2/2
✓ Branch 0 taken 53415234 times.
✓ Branch 1 taken 2967513 times.
56382747 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8785 53415234 down_control_states[i] = raw_control_state[i];
8786 2967513 }
8787
8788
1/2
✓ Branch 0 taken 7801176 times.
✗ Branch 1 not taken.
7801176 if (!replay_is_replaying())
8789 {
8790 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8791 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8792 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8793 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8794 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8795 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8796 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8797 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8798 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8799 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8800 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8801 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8802 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8803 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8804
8805 if(num_joysticks != 0)
8806 {
8807 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8808 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8809 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8810 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8811 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8812 }
8813 else
8814 {
8815 raw_control_state[14] = false;
8816 raw_control_state[15] = false;
8817 raw_control_state[16] = false;
8818 raw_control_state[17] = false;
8819 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8820 }
8821 }
8822
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7801173 times.
7801176 if (replay_is_active())
8823 {
8824
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 6785958 times.
7801173 if (replay_get_version() < 3)
8825 1015215 replay_poll();
8826
3/4
✓ Branch 0 taken 6785958 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5024583 times.
✓ Branch 3 taken 1761375 times.
6785958 else if (replay_is_replaying() && replay_get_version() < 6)
8827 1761375 replay_peek_input();
8828
3/4
✓ Branch 0 taken 5024583 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2057070 times.
✓ Branch 3 taken 2967513 times.
5024583 else if (replay_is_replaying() && replay_version_check(8, 11))
8829 2967513 replay_peek_input();
8830
2/2
✓ Branch 0 taken 6696883 times.
✓ Branch 1 taken 1104290 times.
7801173 if (replay_get_version() == 8)
8831 1104290 update_keys();
8832 7801173 }
8833
8834 // Some test replay files were made before a serious input bug was fixed, so instead
8835 // of re-doing them or tossing them out, just check for that zplay version.
8836
3/4
✓ Branch 0 taken 7801170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 7679270 times.
7801176 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8837
2/2
✓ Branch 0 taken 140421060 times.
✓ Branch 1 taken 7801170 times.
148222230 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8838 {
8839 140421060 control_state[i] = raw_control_state[i];
8840
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 90933750 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
140421060 if (botched_input && !control_state[i])
8841 47077142 down_control_states[i] = false;
8842 140421060 }
8843 7801170 bool did_bad_cutscene_btn = false;
8844
2/2
✓ Branch 0 taken 7801170 times.
✓ Branch 1 taken 140421060 times.
148222230 for(int q = 0; q < 18; ++q)
8845
4/4
✓ Branch 0 taken 6465003 times.
✓ Branch 1 taken 133956057 times.
✓ Branch 2 taken 6464269 times.
✓ Branch 3 taken 734 times.
140421794 if(control_state[q] && !active_cutscene.can_button(q))
8846 {
8847 734 control_state[q] = false;
8848 734 did_bad_cutscene_btn = true;
8849 734 }
8850
2/2
✓ Branch 0 taken 7800655 times.
✓ Branch 1 taken 515 times.
7801170 if(did_bad_cutscene_btn)
8851 515 active_cutscene.error();
8852
8853 7801170 button_press[0]=rButton(control_state[0],button_hold[0]);
8854 7801170 button_press[1]=rButton(control_state[1],button_hold[1]);
8855 7801170 button_press[2]=rButton(control_state[2],button_hold[2]);
8856 7801170 button_press[3]=rButton(control_state[3],button_hold[3]);
8857 7801170 button_press[4]=rButton(control_state[4],button_hold[4]);
8858 7801170 button_press[5]=rButton(control_state[5],button_hold[5]);
8859 7801170 button_press[6]=rButton(control_state[6],button_hold[6]);
8860 7801170 button_press[7]=rButton(control_state[7],button_hold[7]);
8861 7801170 button_press[8]=rButton(control_state[8],button_hold[8]);
8862 7801170 button_press[9]=rButton(control_state[9],button_hold[9]);
8863 7801170 button_press[10]=rButton(control_state[10],button_hold[10]);
8864 7801170 button_press[11]=rButton(control_state[11],button_hold[11]);
8865 7801170 button_press[12]=rButton(control_state[12],button_hold[12]);
8866 7801170 button_press[13]=rButton(control_state[13],button_hold[13]);
8867 7801170 button_press[14]=rButton(control_state[14],button_hold[14]);
8868 7801170 button_press[15]=rButton(control_state[15],button_hold[15]);
8869 7801170 button_press[16]=rButton(control_state[16],button_hold[16]);
8870 7801170 button_press[17]=rButton(control_state[17],button_hold[17]);
8871 7801170 }
8872
8873 // Returns true if any game key is pressed. This is needed because keypressed()
8874 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8875 40250637 bool zc_key_pressed()
8876 //may also need to use zc_getrawkey
8877 {
8878
7/10
✓ Branch 0 taken 32597771 times.
✓ Branch 1 taken 7652866 times.
✓ Branch 2 taken 7652866 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7652866 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6396392 times.
✓ Branch 7 taken 6396392 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2461754 times.
42712391 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8879
4/6
✓ Branch 0 taken 6396392 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6396392 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4844168 times.
✓ Branch 5 taken 4844168 times.
6396392 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8880
4/6
✓ Branch 0 taken 4844168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4844168 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3143220 times.
✓ Branch 5 taken 3143220 times.
4844168 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8881
4/6
✓ Branch 0 taken 3143220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3143220 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2732278 times.
✓ Branch 5 taken 2732278 times.
3143220 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8882
1/2
✓ Branch 0 taken 2732278 times.
✗ Branch 1 not taken.
2732278 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8883
3/4
✓ Branch 0 taken 2612871 times.
✓ Branch 1 taken 119407 times.
✓ Branch 2 taken 2612871 times.
✗ Branch 3 not taken.
2732278 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8884
3/4
✓ Branch 0 taken 2493968 times.
✓ Branch 1 taken 118903 times.
✓ Branch 2 taken 2493968 times.
✗ Branch 3 not taken.
2612871 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8885
3/4
✓ Branch 0 taken 2478823 times.
✓ Branch 1 taken 15145 times.
✓ Branch 2 taken 2478823 times.
✗ Branch 3 not taken.
2493968 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8886
3/4
✓ Branch 0 taken 2465324 times.
✓ Branch 1 taken 13499 times.
✓ Branch 2 taken 2465324 times.
✗ Branch 3 not taken.
2478823 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8887
3/4
✓ Branch 0 taken 2462830 times.
✓ Branch 1 taken 2494 times.
✓ Branch 2 taken 2462830 times.
✗ Branch 3 not taken.
2465324 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8888
3/4
✓ Branch 0 taken 2462612 times.
✓ Branch 1 taken 218 times.
✓ Branch 2 taken 2462612 times.
✗ Branch 3 not taken.
2462830 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8889
3/4
✓ Branch 0 taken 2461773 times.
✓ Branch 1 taken 839 times.
✓ Branch 2 taken 2461773 times.
✗ Branch 3 not taken.
2462612 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8890
2/4
✓ Branch 0 taken 2461773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461773 times.
✗ Branch 3 not taken.
2461773 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8891
2/2
✓ Branch 0 taken 2461754 times.
✓ Branch 1 taken 19 times.
2461773 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8892 72020999 return true;
8893
8894 2461754 return false;
8895 9287211 }
8896
8897 149956017 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8898 {
8899 149956017 bool ret = false, drunkstate = false, rawret = false;;
8900 149956017 bool* flag = &down_control_states[btn];
8901
2/7
✓ Branch 0 taken 140659469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9296548 times.
149956017 switch(btn)
8902 {
8903 case btnF12:
8904 ret = zc_getkey(KEY_F12, ignoreDisable);
8905 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8906 eatEntirely = false;
8907 break;
8908 case btnF11:
8909 ret = zc_getkey(KEY_F11, ignoreDisable);
8910 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8911 eatEntirely = false;
8912 break;
8913 case btnF5:
8914 ret = zc_getkey(KEY_F5, ignoreDisable);
8915 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8916 eatEntirely = false;
8917 break;
8918 case btnQ:
8919 ret = zc_getkey(KEY_Q, ignoreDisable);
8920 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8921 eatEntirely = false;
8922 break;
8923 case btnI:
8924 ret = zc_getkey(KEY_I, ignoreDisable);
8925 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8926 eatEntirely = false;
8927 break;
8928 case btnM:
8929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9296548 times.
9296548 if(FFCore.kb_typing_mode) return false;
8930 9296548 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8931 9296548 eatEntirely = false;
8932 9296548 break;
8933 default: //control_state[] index
8934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140659469 times.
140659469 if(FFCore.kb_typing_mode) return false;
8935
5/6
✓ Branch 0 taken 139859690 times.
✓ Branch 1 taken 799779 times.
✓ Branch 2 taken 2237468 times.
✓ Branch 3 taken 137622222 times.
✓ Branch 4 taken 2237468 times.
✗ Branch 5 not taken.
140659469 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8936
2/2
✓ Branch 0 taken 8036378 times.
✓ Branch 1 taken 132623091 times.
140659469 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8937
4/4
✓ Branch 0 taken 126521127 times.
✓ Branch 1 taken 14138342 times.
✓ Branch 2 taken 3004 times.
✓ Branch 3 taken 14135338 times.
154797811 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8938 140659469 rawret = raw_control_state[btn];
8939 140659469 }
8940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149956017 times.
149956017 assert(flag);
8941
2/2
✓ Branch 0 taken 95473276 times.
✓ Branch 1 taken 54482741 times.
149956017 if(press)
8942 {
8943
2/2
✓ Branch 0 taken 2888985 times.
✓ Branch 1 taken 51593756 times.
54482741 if(peek)
8944 2888985 ret = rButtonPeek(ret, *flag);
8945
2/2
✓ Branch 0 taken 50384650 times.
✓ Branch 1 taken 1209106 times.
51593756 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
8946 1209106 else ret = rButton(ret, *flag, rawret);
8947 54482741 }
8948
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149956017 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149956017 if(eatEntirely && ret) control_state[btn] = false;
8949
3/4
✓ Branch 0 taken 112376241 times.
✓ Branch 1 taken 37579776 times.
✓ Branch 2 taken 112376241 times.
✗ Branch 3 not taken.
149956017 if(drunk && drunkstate) ret = !ret;
8950 149956017 return ret;
8951 149956017 }
8952
8953 7465295 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8954 {
8955 7465295 byte ret = 0;
8956
2/2
✓ Branch 0 taken 5485975 times.
✓ Branch 1 taken 1979320 times.
7465295 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8957
2/2
✓ Branch 0 taken 7334481 times.
✓ Branch 1 taken 130814 times.
7465295 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8958
2/2
✓ Branch 0 taken 7334606 times.
✓ Branch 1 taken 130689 times.
7465295 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8959
2/2
✓ Branch 0 taken 7334606 times.
✓ Branch 1 taken 130689 times.
7465295 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8960
2/2
✓ Branch 0 taken 7334606 times.
✓ Branch 1 taken 130689 times.
7465295 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8961
2/2
✓ Branch 0 taken 7334606 times.
✓ Branch 1 taken 130689 times.
7465295 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8962
2/2
✓ Branch 0 taken 7334606 times.
✓ Branch 1 taken 130689 times.
7465295 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8963
2/2
✓ Branch 0 taken 7334606 times.
✓ Branch 1 taken 130689 times.
7465295 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8964 7465295 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8965 }
8966
8967 1114 byte checkIntBtnVal(byte intbtn, byte vals)
8968 {
8969 1114 return intbtn&vals;
8970 }
8971
8972 1767437 bool Up()
8973 {
8974 1767437 return getInput(btnUp);
8975 }
8976 147234 bool Down()
8977 {
8978 147234 return getInput(btnDown);
8979 }
8980 257723 bool Left()
8981 {
8982 257723 return getInput(btnLeft);
8983 }
8984 286925 bool Right()
8985 {
8986 286925 return getInput(btnRight);
8987 }
8988 164908 bool cAbtn()
8989 {
8990 164908 return getInput(btnA);
8991 }
8992 1411891 bool cBbtn()
8993 {
8994 1411891 return getInput(btnB);
8995 }
8996 bool cSbtn()
8997 {
8998 return getInput(btnS);
8999 }
9000 68744 bool cLbtn()
9001 {
9002 68744 return getInput(btnL);
9003 }
9004 68744 bool cRbtn()
9005 {
9006 68744 return getInput(btnR);
9007 }
9008 bool cPbtn()
9009 {
9010 return getInput(btnP);
9011 }
9012 bool cEx1btn()
9013 {
9014 return getInput(btnEx1);
9015 }
9016 bool cEx2btn()
9017 {
9018 return getInput(btnEx2);
9019 }
9020 bool cEx3btn()
9021 {
9022 return getInput(btnEx3);
9023 }
9024 bool cEx4btn()
9025 {
9026 return getInput(btnEx4);
9027 }
9028 bool AxisUp()
9029 {
9030 return getInput(btnAxisUp);
9031 }
9032 bool AxisDown()
9033 {
9034 return getInput(btnAxisDown);
9035 }
9036 bool AxisLeft()
9037 {
9038 return getInput(btnAxisLeft);
9039 }
9040 bool AxisRight()
9041 {
9042 return getInput(btnAxisRight);
9043 }
9044
9045 bool cMbtn()
9046 {
9047 return getInput(btnM);
9048 }
9049 bool cF12()
9050 {
9051 return getInput(btnF12);
9052 }
9053 bool cF11()
9054 {
9055 return getInput(btnF11);
9056 }
9057 bool cF5()
9058 {
9059 return getInput(btnF5);
9060 }
9061 bool cQ()
9062 {
9063 return getInput(btnQ);
9064 }
9065 bool cI()
9066 {
9067 return getInput(btnI);
9068 }
9069
9070 130270 bool rUp()
9071 {
9072 130270 return getInput(btnUp, true);
9073 }
9074 130174 bool rDown()
9075 {
9076 130174 return getInput(btnDown, true);
9077 }
9078 130122 bool rLeft()
9079 {
9080 130122 return getInput(btnLeft, true);
9081 }
9082 129657 bool rRight()
9083 {
9084 129657 return getInput(btnRight, true);
9085 }
9086 1296 bool rAbtn()
9087 {
9088 1296 return getInput(btnA, true);
9089 }
9090 1296 bool rBbtn()
9091 {
9092 1296 return getInput(btnB, true);
9093 }
9094 7397110 bool rSbtn()
9095 {
9096 7397110 return getInput(btnS, true);
9097 }
9098 9287211 bool rMbtn()
9099 {
9100 9287211 return getInput(btnM, true);
9101 }
9102 129441 bool rLbtn()
9103 {
9104 129441 return getInput(btnL, true);
9105 }
9106 129436 bool rRbtn()
9107 {
9108 129436 return getInput(btnR, true);
9109 }
9110 7333574 bool rPbtn()
9111 {
9112 7333574 return getInput(btnP, true);
9113 }
9114 bool rEx1btn()
9115 {
9116 return getInput(btnEx1, true);
9117 }
9118 bool rEx2btn()
9119 {
9120 return getInput(btnEx2, true);
9121 }
9122 140087 bool rEx3btn()
9123 {
9124 140087 return getInput(btnEx3, true);
9125 }
9126 140087 bool rEx4btn()
9127 {
9128 140087 return getInput(btnEx4, true);
9129 }
9130 bool rAxisUp()
9131 {
9132 return getInput(btnAxisUp, true);
9133 }
9134 bool rAxisDown()
9135 {
9136 return getInput(btnAxisDown, true);
9137 }
9138 bool rAxisLeft()
9139 {
9140 return getInput(btnAxisLeft, true);
9141 }
9142 bool rAxisRight()
9143 {
9144 return getInput(btnAxisRight, true);
9145 }
9146
9147 bool rF11()
9148 {
9149 return getInput(btnF11, true);
9150 }
9151 bool rQ()
9152 {
9153 return getInput(btnQ, true);
9154 }
9155 bool rI()
9156 {
9157 return getInput(btnI, true);
9158 }
9159
9160 18227830 bool DrunkUp()
9161 {
9162 18227830 return getInput(btnUp, false, true);
9163 }
9164 16890614 bool DrunkDown()
9165 {
9166 16890614 return getInput(btnDown, false, true);
9167 }
9168 10289030 bool DrunkLeft()
9169 {
9170 10289030 return getInput(btnLeft, false, true);
9171 }
9172 8834523 bool DrunkRight()
9173 {
9174 8834523 return getInput(btnRight, false, true);
9175 }
9176 8036020 bool DrunkcAbtn()
9177 {
9178 8036020 return getInput(btnA, false, true);
9179 }
9180 8017468 bool DrunkcBbtn()
9181 {
9182 8017468 return getInput(btnB, false, true);
9183 }
9184 7264444 bool DrunkcEx1btn()
9185 {
9186 7264444 return getInput(btnEx1, false, true);
9187 }
9188 7264464 bool DrunkcEx2btn()
9189 {
9190 7264464 return getInput(btnEx2, false, true);
9191 }
9192 bool DrunkcSbtn()
9193 {
9194 return getInput(btnS, false, true);
9195 }
9196 bool DrunkcMbtn()
9197 {
9198 return getInput(btnM, false, true);
9199 }
9200 bool DrunkcLbtn()
9201 {
9202 return getInput(btnL, false, true);
9203 }
9204 bool DrunkcRbtn()
9205 {
9206 return getInput(btnR, false, true);
9207 }
9208 bool DrunkcPbtn()
9209 {
9210 return getInput(btnP, false, true);
9211 }
9212
9213 bool DrunkrUp()
9214 {
9215 return getInput(btnUp, true, true);
9216 }
9217 bool DrunkrDown()
9218 {
9219 return getInput(btnDown, true, true);
9220 }
9221 bool DrunkrLeft()
9222 {
9223 return getInput(btnLeft, true, true);
9224 }
9225 bool DrunkrRight()
9226 {
9227 return getInput(btnRight, true, true);
9228 }
9229 6082228 bool DrunkrAbtn()
9230 {
9231 6082228 return getInput(btnA, true, true);
9232 }
9233 6099060 bool DrunkrBbtn()
9234 {
9235 6099060 return getInput(btnB, true, true);
9236 }
9237 71669 bool DrunkrEx1btn()
9238 {
9239 71669 return getInput(btnEx1, true, true);
9240 }
9241 71662 bool DrunkrEx2btn()
9242 {
9243 71662 return getInput(btnEx2, true, true);
9244 }
9245 bool DrunkrEx3btn()
9246 {
9247 return getInput(btnEx3, true, true);
9248 }
9249 bool DrunkrEx4btn()
9250 {
9251 return getInput(btnEx4, true, true);
9252 }
9253 bool DrunkrSbtn()
9254 {
9255 return getInput(btnS, true, true);
9256 }
9257 bool DrunkrMbtn()
9258 {
9259 return getInput(btnM, true, true);
9260 }
9261 6689226 bool DrunkrLbtn()
9262 {
9263 6689226 return getInput(btnL, true, true);
9264 }
9265 6685751 bool DrunkrRbtn()
9266 {
9267 6685751 return getInput(btnR, true, true);
9268 }
9269 bool DrunkrPbtn()
9270 {
9271 return getInput(btnP, true, true);
9272 }
9273
9274 9337 void eat_buttons()
9275 {
9276 9337 getInput(btnA, true, false, true);
9277 9337 getInput(btnB, true, false, true);
9278 9337 getInput(btnS, true, false, true);
9279 9337 getInput(btnM, true, false, true);
9280 9337 getInput(btnL, true, false, true);
9281 9337 getInput(btnR, true, false, true);
9282 9337 getInput(btnP, true, false, true);
9283 9337 getInput(btnEx1, true, false, true);
9284 9337 getInput(btnEx2, true, false, true);
9285 9337 getInput(btnEx3, true, false, true);
9286 9337 getInput(btnEx4, true, false, true);
9287 9337 }
9288
9289 // Is true for the _first frame_ of a key press.
9290 // But! it is possible that a script manually sets the value of KeyPress,
9291 // in which case it will be restored to the "true" value based on `key_current_frame`
9292 // and `key_previous_frame` on the next frame.
9293 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9294 {
9295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9297 {
9298 case KEY_F7:
9299 case KEY_F8:
9300 case KEY_F9:
9301 return KeyPress[k];
9302
9303 default:
9304
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9305 }
9306 14 }
9307
9308 // Is true for _every frame_ a key is held down.
9309 // But! it is possible that a script manually sets the value of KeyInput,
9310 // in which case it will be restored to the "true" value based on `key_current_frame`
9311 // on the next frame.
9312 bool zc_getkey(int32_t k, bool ignoreDisable)
9313 {
9314 if(ignoreDisable) return KeyInput[k];
9315 switch(k)
9316 {
9317 case KEY_F7:
9318 case KEY_F8:
9319 case KEY_F9:
9320 return KeyInput[k];
9321
9322 default:
9323 return KeyInput[k] && !disabledKeys[k];
9324 }
9325 }
9326
9327 // Reads (and then clears) the current frame key state directly.
9328 // Scripts can also modify `key_current_frame`.
9329 303 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9330 {
9331
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 301 times.
303 if(zc_getrawkey(k, ignoreDisable))
9332 {
9333 2 _key[k]=key[k]=key_current_frame[k]=0;
9334 2 return true;
9335 }
9336 301 _key[k]=key[k]=key_current_frame[k]=0;
9337 301 return false;
9338 303 }
9339
9340 // Reads the current frame key state directly.
9341 // Scripts can also modify `key_current_frame`.
9342 63252960 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9343 {
9344
2/2
✓ Branch 0 taken 53965721 times.
✓ Branch 1 taken 9287239 times.
63252960 if(ignoreDisable) return key_current_frame[k];
9345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9287239 times.
9287239 switch(k)
9346 {
9347 case KEY_F7:
9348 case KEY_F8:
9349 case KEY_F9:
9350 return key_current_frame[k];
9351
9352 default:
9353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9287239 times.
9287239 return key_current_frame[k] && !disabledKeys[k];
9354 }
9355 63252960 }
9356
9357 // Only used for a handful of keys, like tilde and Function keys.
9358 // This state is never read within the game.
9359 // It exists so that all keyboard input still functions during replay,
9360 // without inadvertently doing things like toggling throttling if the player
9361 // presses ~
9362 9287211 bool zc_get_system_key(int32_t k)
9363 {
9364 9287211 return key_system[k];
9365 }
9366
9367 // True for the _first_ frame of a key press.
9368 83584899 bool zc_read_system_key(int32_t k)
9369 {
9370 83584899 return key_system_press[k];
9371 }
9372
9373 1179475797 bool is_system_key(int32_t k)
9374 {
9375
2/2
✓ Branch 0 taken 1095890898 times.
✓ Branch 1 taken 83584899 times.
1179475797 switch (k)
9376 {
9377 case KEY_BACKQUOTE:
9378 case KEY_CLOSEBRACE:
9379 case KEY_END:
9380 case KEY_HOME:
9381 case KEY_OPENBRACE:
9382 case KEY_PGDN:
9383 case KEY_PGUP:
9384 case KEY_TAB:
9385 case KEY_TILDE:
9386 83584899 return true;
9387 }
9388 1095890898 return is_Fkey(k);
9389 1179475797 }
9390
9391 9287211 void update_system_keys()
9392 {
9393
2/2
✓ Branch 0 taken 1179475797 times.
✓ Branch 1 taken 9287211 times.
1188763008 for (int32_t q = 0; q < 127; ++q)
9394 {
9395
2/2
✓ Branch 0 taken 195031431 times.
✓ Branch 1 taken 984444366 times.
1179475797 if (!is_system_key(q))
9396 984444366 continue;
9397
9398 195031431 key_system[q] = key[q];
9399
1/2
✓ Branch 0 taken 195031431 times.
✗ Branch 1 not taken.
195031431 key_system_press[q] = key_system[q] && !key_system_previous[q];
9400 195031431 key_system_previous[q] = key_system[q];
9401 195031431 }
9402 9287211 }
9403
9404 10391501 void update_keys()
9405 {
9406
2/2
✓ Branch 0 taken 1319720627 times.
✓ Branch 1 taken 10391501 times.
1330112128 for (int32_t q = 0; q < 127; ++q)
9407 {
9408 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9409
1/2
✓ Branch 0 taken 1319720627 times.
✗ Branch 1 not taken.
1319720627 if (!replay_is_replaying())
9410 key_current_frame[q] = key[q];
9411
9412
2/2
✓ Branch 0 taken 1309932100 times.
✓ Branch 1 taken 9788527 times.
1319720627 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9413 1319720627 KeyInput[q] = key_current_frame[q];
9414 1319720627 key_previous_frame[q] = key_current_frame[q];
9415 1319720627 }
9416 10391501 }
9417
9418 bool zc_disablekey(int32_t k, bool val)
9419 {
9420 switch(k)
9421 {
9422 case KEY_F7:
9423 case KEY_F8:
9424 case KEY_F9:
9425 return false;
9426
9427 default:
9428 disabledKeys[k] = val;
9429 return true;
9430 }
9431 }
9432
9433 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9434 {
9435 timer=timer;
9436 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9437 }
9438